Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Cartesian to angle (http://www.chiefdelphi.com/forums/showthread.php?t=96187)

Ether 23-07-2011 14:51

Re: Cartesian to angle
 
Quote:

Originally Posted by Ether (Post 1069977)
Here's a simple C function CWYdeg(x,y) which returns an angle from 0 to 360 degrees measured clockwise from the +Y Cartesian axis when given Cartesian coordinates (x,y).

Using single-precision floats, the accuracy is better than +/-0.17 degree over the entire 0 to 360 range.


I've refined the solution. I like these coefficients better:

a = -15.6526435831
b = 60.6626425889
c = -0.0049997982


Although the accuracy is ever so slightly less with these revised coefficients (+/-0.21 instead of +/-0.17 degrees), there is virtually no discontinuity (0.01 degree) at the octant boundaries.




All times are GMT -5. The time now is 18:58.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi