We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexSuggestions & BugsSoftware,  Documentation,  Website Suggestions › enhancement suggestion: useful angle-shifting code
Page Index Toggle Pages: 1
enhancement suggestion: useful angle-shifting code (Read 1231 times)
enhancement suggestion: useful angle-shifting code
May 12th, 2009, 6:24pm
 
Hi,
this little scrap of code has been so useful to me that it ends up pasted into almost all my sketches.  Maybe it would be useful to other (beginning) programmers and could find a home in the API?
It just finds the X and Y coordinates a given distance and angle from a starting point.

float shiftX(float startX, float angle, float speed){
 return (startX + (speed * cos(angle)));
}

float shiftY(float startY, float angle, float speed) {
 return (startY + (speed * sin(angle)));
}

--Ben
Re: enhancement suggestion: useful angle-shifting code
Reply #1 - Jun 13th, 2009, 5:20pm
 
I end up putting this exact same thing in every program I write that involves things moving along angles.
Page Index Toggle Pages: 1