www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/28/15:07:41

Date: Sat, 28 Feb 1998 12:07:21 -0800 (PST)
Message-Id: <199802282007.MAA15146@adit.ap.net>
Mime-Version: 1.0
To: " [iC]" <jan AT narvik DOT crosswinds DOT net>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: converting grades speed ???

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019