1
\$\begingroup\$

This question can be simplified to: If you lean a pencil of a certain length at a certain angle what is the x and y position of the tip? So, basically, I am making a game that plots a balls path through the air as it travels. I want the user to enter an angle and velocity to launch a ball at and get the program to convert that to an x and y velocity so that it can work out how to plot the balls movement across the screen. The x velocity doesn't change through the simulation but the y velocity will decrease constantly until the ball touches the ground again. This is why I referenced to a pencil because it relates to turtle graphics calculations.

\$\endgroup\$
3
\$\begingroup\$

This is a straightforward application of the Unit Circle, multiplied by the length of the vector we want as output:

x = length * cos(angle)
y = length * sin(angle)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.