: [1]
   
: Yaw formula  ( 4673 )
0 and 1 Guest are viewing this topic.
*
Karma: +0/-0
: 9
Offline Offline
« : March 23, 2010, 09:04:54 AM »

Hello!

I've been given a piece of code that is used to calculate yaw. I believe it to be correct (however if it's not I'd love to hear it).
Since I don't know much about programming I'm attempting to bring it back to its original formulas, so I can get it to work using LabVIEW (which has a graphical interface and is much easier to use for me).
This is the original piece of code:

Code: [Select]
float calc_yaw(struct ir_t* ir) {
float x;

x = ir->ax - 512;
x *= WIIMOTE_FOV_COEFFICIENT / 512.0;
       
        return RAD_TO_DEGREE( atanf(x) );

Which I think translates to this:

Raw X Values (ax) - 512
=> X * (0.39f)/512)
=> atan(X)

(With f being Pi/4)

And then all you have to do is convert the (radian) number to degrees (=> * 360/2Pi)
Does this look okay?
: [1]
   
 
:  

Clicky Web Analytics