Author Topic: Yaw formula  (Read 5071 times)

Offline Rorschach

  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
on: March 23, 2010, 09:04:54 AM

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;
        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?