[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Rotating an image so much that it looks at a Vector
"Jan Filip Tristan" <blenderkid@xxxxxx> asked:
> Think of a triangle with a=3 b=4 and c=5 and one angle 90
> degrees. Now I want to calculate the two other angels.
> With this angels you can rotate the Image. My question is: How to
> calculate them, do I need arccos.
Arccosine isn't necessary; arctangent is probably the best function to
use. For example:
>>> import math
>>> math.degrees(math.atan2(3,4))
36.86989764584402
which tells you that one of your angles is about 37 degrees.
This is pretty well documented in the Python docs:
http://docs.python.org/lib/module-math.html
And if you need to review your trigonometry, Wikipedia is, of course, a
reference:
http://en.wikipedia.org/wiki/Trigonometric_function
-Dave LeCompte