Wednesday, January 2, 2019

physics - How do you convert angle with velocity to x velocity and y velocity?


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.



Answer



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)

No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...