After going through your comment, I don't think that you are getting two angles in radians for c[1] and c[3]. Rather, you are getting direction cosines. If you were getting angles in radians, the value would range from -pi to pi. Rather, the value goes from -1 to 1 (i.e. cos(-pi) to cos(pi)).
You can change the value first to an angle in radians and then to degrees if that is what you want. Just as a caveat, the cosine of angles is symmetric ...
So for:
In [12]: zip(angles, (cos(angles)))
Out[12]:
[(-3.1415926535897931, -1.0),
(-2.8108986900540254, -0.94581724170063464),
(-2.4802047265182576, -0.78914050939639346),
(-2.1495107629824899, -0.5469481581224267),
(-1.8188167994467224, -0.24548548714079912),
(-1.4881228359109546, 0.082579345472332394),
(-1.1574288723751871, 0.40169542465296937),
(-0.82673490883941936, 0.67728157162574099),
(-0.49604094530365161, 0.87947375120648907),
(-0.16534698176788387, 0.98636130340272232),
(0.16534698176788387, 0.98636130340272232),
(0.49604094530365161, 0.87947375120648907),
(0.82673490883941891, 0.67728157162574132),
(1.1574288723751867, 0.40169542465296976),
(1.4881228359109544, 0.082579345472332616),
(1.8188167994467221, -0.2454854871407989),
(2.1495107629824899, -0.5469481581224267),
(2.4802047265182576, -0.78914050939639346),
(2.8108986900540254, -0.94581724170063464),
(3.1415926535897931, -1.0)]
But,
In [11]: zip(angles, arccos(cos(angles)))
Out[11]:
[(-3.1415926535897931, 3.1415926535897931),
(-2.8108986900540254, 2.8108986900540254),
(-2.4802047265182576, 2.4802047265182576),
(-2.1495107629824899, 2.1495107629824899),
(-1.8188167994467224, 1.8188167994467224),
(-1.4881228359109546, 1.4881228359109546),
(-1.1574288723751871, 1.1574288723751871),
(-0.82673490883941936, 0.82673490883941936),
(-0.49604094530365161, 0.49604094530365156),
(-0.16534698176788387, 0.16534698176788418),
(0.16534698176788387, 0.16534698176788418),
(0.49604094530365161, 0.49604094530365156),
(0.82673490883941891, 0.82673490883941891),
(1.1574288723751867, 1.1574288723751867),
(1.4881228359109544, 1.4881228359109544),
(1.8188167994467221, 1.8188167994467221),
(2.1495107629824899, 2.1495107629824899),
(2.4802047265182576, 2.4802047265182576),
(2.8108986900540254, 2.8108986900540254),
(3.1415926535897931, 3.1415926535897931)]
Which means that getting your angles from your direction cosines, you will need to do:
In [13]: def toAng(a): return sign(a)*arccos(a)
which will give you your correct angles:
In [19]: zip(angles, toAng(cos(angles)))
Out[19]:
[(-3.1415926535897931, -3.1415926535897931),
(-2.8108986900540254, -2.8108986900540254),
(-2.4802047265182576, -2.4802047265182576),
(-2.1495107629824899, -2.1495107629824899),
(-1.8188167994467224, -1.8188167994467224),
(-1.4881228359109546, 1.4881228359109546),
(-1.1574288723751871, 1.1574288723751871),
(-0.82673490883941936, 0.82673490883941936),
(-0.49604094530365161, 0.49604094530365156),
(-0.16534698176788387, 0.16534698176788418),
(0.16534698176788387, 0.16534698176788418),
(0.49604094530365161, 0.49604094530365156),
(0.82673490883941891, 0.82673490883941891),
(1.1574288723751867, 1.1574288723751867),
(1.4881228359109544, 1.4881228359109544),
(1.8188167994467221, -1.8188167994467221),
(2.1495107629824899, -2.1495107629824899),
(2.4802047265182576, -2.4802047265182576),
(2.8108986900540254, -2.8108986900540254),
(3.1415926535897931, -3.1415926535897931)]
Finally, if you need to convert it to degrees, you can just do:
In [20]: def toAng(a): return 180*sign(a)*arccos(a)/pi
In [21]: zip(angles, toAng(cos(angles)))
Out[21]:
[(-3.1415926535897931, -180.0),
(-2.8108986900540254, -161.05263157894737),
(-2.4802047265182576, -142.10526315789474),
(-2.1495107629824899, -123.1578947368421),
(-1.8188167994467224, -104.21052631578948),
(-1.4881228359109546, 85.263157894736835),
(-1.1574288723751871, 66.31578947368422),
(-0.82673490883941936, 47.368421052631582),
(-0.49604094530365161, 28.421052631578949),
(-0.16534698176788387, 9.4736842105263346),
(0.16534698176788387, 9.4736842105263346),
(0.49604094530365161, 28.421052631578949),
(0.82673490883941891, 47.368421052631554),
(1.1574288723751867, 66.315789473684191),
(1.4881228359109544, 85.263157894736835),
(1.8188167994467221, -104.21052631578947),
(2.1495107629824899, -123.1578947368421),
(2.4802047265182576, -142.10526315789474),
(2.8108986900540254, -161.05263157894737),
(3.1415926535897931, -180.0)]
Which gives you the right angles in degrees ...
Note I am using an environment where sign
, pi
etc are numpy objects. In your program, you might have ti import them separately.
math.degrees(rads)
. How you would convert two radian values into one degree value is totally unclear to me, though... Or do you just want to convert each one of them?ReadProcessMemory
to read the players coordinates and heading in a game. I want to create a map that will show you your current location and heading. The values I get from the game are in radians, and I need to rotate a surface in pygame according to the player's orientation.c[1]
is -1 to 0 to the west, 0 to 1 to the east, and c[3] is -1 to 0 to the south, and 0 to 1 to the north. If the player rotates 360 degrees, neitherc[1]
orc[3]
can tell you which way you are facing by themselves.