N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
Diff: util/transforms.cpp
- Revision:
- 27:846c08fb3697
- Parent:
- 14:1cc975207995
- Child:
- 33:e7b132029bae
--- a/util/transforms.cpp Tue Mar 10 17:51:38 2015 +0000 +++ b/util/transforms.cpp Sat Mar 14 18:51:36 2015 +0000 @@ -12,16 +12,22 @@ *b = -0.5 * alpha + sqrt(3.0f) / 2.0f * beta; } -void Transforms::Parke(float alpha, float beta, float theta, float *d, float *q) { +void Transforms::Parke(float beta, float alpha, float theta, float *d, float *q) { + //reversed alpha and beta order to make d and q ~=constant. + //I did this because alpha was found to be sinusoidal and beta was found to be cosinusoidal. the equation has to take the form sin^2 + cos^2, not sin*cos + sin*cos. float cos = FastCos(theta); float sin = FastSin(theta); + *d = alpha * cos + beta * sin; *q = -alpha * sin + beta * cos; + } -void Transforms::InverseParke(float d, float q, float theta, float *alpha, float *beta) { +void Transforms::InverseParke(float d, float q, float theta, float *alpha, float *beta) { float cos = FastCos(theta); float sin = FastSin(theta); + *alpha = cos * d - sin * q; - *beta = sin * d + cos * q; + *beta = sin * d + cos * q; + } \ No newline at end of file