Vector to degrees
Hi!
I''ve got a (hopefully) simple question:
How can I convert a unified 2D Vector into a single degree-value?
e.g. (just estimated)
0,1 -> 0
1,1 -> 45
1,0 -> 90
1,-1 -> 135
0,-1 -> 180
......
Do you have any ideas? Thanks!!!!!!!!!!!!!!!!!
use arctan(), which converts x/y values into degrees. This should be standard in your compiler''s math library.
------------------------------------------------
The wind shear alone from a pink golfball can take the head off a 90-pound midget from 300 yards.
-Six String Samurai
------------------------------------------------
The wind shear alone from a pink golfball can take the head off a 90-pound midget from 300 yards.
-Six String Samurai
_________________________________________________________________________________The wind shear alone from a pink golfball can take the head off a 90-pound midget from 300 yards.-Six String Samurai
In C, atan2(x,y) works better than atan(x/y) : no singularities and it covers all four quadrants. Results are in radians not degrees.
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement