> the result should be 30 degrees but I'm getting 27 or > it should be 60 and I'm getting 63. atan2() returns > rads, so I'm converting them to degrees and then > rounding that result to an integer. Is there a better > way to do this: > > double radAngle,difx,dify ; > int degAngle; > > radAngle = atan2(dify,difx); > degAngle = round(radAngle*(180.0/(22.0/7.0))); > > I'm assuming there's at least a Pi constant somewhere
the 22/7 =~ 3.142857is a very rough approximation for Pi, 3.14159265359. try substituting this and see if it gets you within about a half degree so your rounding will work better (round as late in the calculations as possible as a general rule) - David M -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/
