BugInTheSYS

Untitled

Jan 27th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.42 KB | None | 0 0
  1. static void Circle2DGI( float x, float y, out float distance, out float angle ) {
  2.   float inverseDistance;
  3.   distance = ( float )Math.Sqrt( x * x + y * y );
  4.   inverseDistance = 1.0f / distance;
  5.   x *= inverseDistance;
  6.   y *= inverseDistance;
  7.   if( x >= 0 ) {
  8.     angle = ( float )Math.Acos( y ) * 180.0f / ( float )Math.PI
  9.   } else {
  10.     angle = 180.0f + ( float )Math.Acos( -y ) * 180.0f / ( float )Math.PI;
  11.   }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment