View Single Post
  #30   Spotlight this post!  
Unread 21-07-2011, 22:01
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,125
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Cartesian to angle



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.

Using a similar technique, it is straightforward to create a function which returns angles either clockwise or counterclockwise, from the +X or -X or +Y or -Y axis, in the range 0 to 360 or -180 to +180 or 0 to 2pi or -pi to pi