Mail Archives: djgpp/1998/02/28/15:07:41
At 12:20 2/28/1998 +0100, [iC] wrote:
>Uh, this might not be the right group to poste this question, but anyway ...
>
>Does anybody knows how to convert speed and angel to +-x and y ?
>like if the angel of the object is 45 grades and speed is one the x and y
^^^^^^
Do you mean `degrees'?
>values vould be -1 both, and if the object has an angel of 90 and speed of 5
^^^^^^^^^^^^^^^^^^^^^^^
No they wouldn't! They would be sqrt(2)/2. See below.
>the y would have the value -5 and x = 0. uhh get the idea ?? ;-)
If you're using standard geometric conventions, y would be +5.
>Have anybody done somthing like this or have any ideas ?
It's simple trigonomentry/vector math. In brief:
x = speed * cos(angle)
y = speed * sin(angle)
Note that to use the C trig functions, you must convert the argument into
radians. There are (2*pi) radians in a full circle. So:
radians = (degrees * 180) / pi
Nate Eldredge
eldredge AT ap DOT net
- Raw text -