Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: mike_g on March 12, 2007

Title: Getting a second co-ordinate
Post by: mike_g on March 12, 2007
Its kind of embarrasing asking such a simple maths question but:

Say I have a start x/y co-ordinate, an angle in degrees, and a distance. How can I get the end x/y co-ordinates from this?
Title: Re: Getting a second co-ordinate
Post by: zawran on March 12, 2007
If I remember correctly, you can do it something like this:

Code: [Select]
endXpos = startXpos + sin( angle ) * distance
endYpos = startYpos + cos( angle ) * distance
Title: Re: Getting a second co-ordinate
Post by: mike_g on March 12, 2007
Thanks man, I'll try that out.

[edit]Yeah works fine :)[/edit]
Title: Re: Getting a second co-ordinate
Post by: Shockwave on March 12, 2007
Don't be embarrased asking questions, simple or difficult they keep the board alive :) Have some good karma guys.