N K
/
GaNtroller
a fork of priustroller
Fork of priustroller_current by
util/transforms.cpp@11:dccbaa9274c5, 2015-03-08 (annotated)
- Committer:
- bwang
- Date:
- Sun Mar 08 08:37:38 2015 +0000
- Revision:
- 11:dccbaa9274c5
- Child:
- 14:1cc975207995
--Initial Commit: 03-08-2015 new context-based code; no more timers (=easier debugging)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bwang | 11:dccbaa9274c5 | 1 | #include "includes.h" |
bwang | 11:dccbaa9274c5 | 2 | #include "transforms.h" |
bwang | 11:dccbaa9274c5 | 3 | #include "fastmath.h" |
bwang | 11:dccbaa9274c5 | 4 | |
bwang | 11:dccbaa9274c5 | 5 | void Transforms::Clarke(float a, float b, float *alpha, float *beta) { |
bwang | 11:dccbaa9274c5 | 6 | *alpha = a; |
bwang | 11:dccbaa9274c5 | 7 | *beta = (a + 2.0f * b)/sqrt(3.0f); |
bwang | 11:dccbaa9274c5 | 8 | } |
bwang | 11:dccbaa9274c5 | 9 | |
bwang | 11:dccbaa9274c5 | 10 | void Transforms::Parke(float alpha, float beta, float theta, float *d, float *q) { |
bwang | 11:dccbaa9274c5 | 11 | float cos = FastCos(theta); |
bwang | 11:dccbaa9274c5 | 12 | float sin = FastSin(theta); |
bwang | 11:dccbaa9274c5 | 13 | *d = alpha * cos + beta * sin; |
bwang | 11:dccbaa9274c5 | 14 | *q = -alpha * sin + beta * cos; |
bwang | 11:dccbaa9274c5 | 15 | } |
bwang | 11:dccbaa9274c5 | 16 | |
bwang | 11:dccbaa9274c5 | 17 | void Transforms::InverseParke(float d, float q, float theta, float *alpha, float *beta) { |
bwang | 11:dccbaa9274c5 | 18 | float cos = FastCos(theta); |
bwang | 11:dccbaa9274c5 | 19 | float sin = FastSin(theta); |
bwang | 11:dccbaa9274c5 | 20 | *alpha = cos * d - sin * q; |
bwang | 11:dccbaa9274c5 | 21 | *beta = sin * d + cos * q; |
bwang | 11:dccbaa9274c5 | 22 | } |