a little physics help
Started by Botyto, Oct 31 2011 10:26 AM
4 replies to this topic
#1
Posted 31 October 2011 - 10:26 AM
Hi, I'm having some trouble comming up with a formula for calculating the position of an object in a certain point in time. So, let's say I have an object at x=0 y=0 with starting speed=spd at direction=angl and gravity=G. I need a formula to calculate the X and Y position of that object at any time... so let's say the instance is at 0 0, at step 1, and I need to calculate the position at step 20. How to do that? Tell me if you have any idea, please .. thanks in advance!
#2
Posted 31 October 2011 - 03:12 PM
Well usually with this kind of thing don't you need to know the distance you will be traveling? Like you are starting at (0,0) and you are moving to (32,64). Then you could find out the time it takes to move from your initial point to the final point as well as trace the actually position you are at while you are moving.
#3
Posted 31 October 2011 - 03:34 PM
You can use the equations of motion to determine the position. http://en.wikipedia....tions_of_motion
As GM has the horizontal and vertical components of the velocity built in, using "s = ut + 0.5a(t)^2":
Edit: It should work as long as the hspeed and vspeed don't change. You might want to store them in variables at the start just to make sure.
Edit 2: This also assumes that gravity's facing downwards. It'll be a bit more complicated if it's not
- You'll need to find the horizontal and vertical components of gravity and then put them in as acceleration. Also t is in seconds so you'll need to convert it to steps (room_speed = 1 second).
As GM has the horizontal and vertical components of the velocity built in, using "s = ut + 0.5a(t)^2":
x = hspeed*t + xstart; y = vspeed*t + 0.5*G*(t)^2 + ystart;
Edit: It should work as long as the hspeed and vspeed don't change. You might want to store them in variables at the start just to make sure.
//Create or somewhere where you start to set its motion. vx = hspeed; vy = vspeed; //Step x = vx*t + xstart; y = vy*t + 0.5*G*(t)^2 + ystart;
Edit 2: This also assumes that gravity's facing downwards. It'll be a bit more complicated if it's not
Edited by Panda_196, 31 October 2011 - 03:53 PM.
#4
Posted 31 October 2011 - 04:31 PM
thanks
it works
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











