Jump to content


Photo

a little physics help


  • Please log in to reply
4 replies to this topic

#1 Botyto

Botyto

    GMC Member

  • GMC Member
  • 1247 posts

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! :)
  • 0

#2 kremling

kremling

    GMC Member

  • GMC Member
  • 146 posts

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.
  • 0

#3 Panda_196

Panda_196

    GMC Member

  • New Member
  • 156 posts

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":
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 :unsure: - 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).

Edited by Panda_196, 31 October 2011 - 03:53 PM.

  • 0

#4 Botyto

Botyto

    GMC Member

  • GMC Member
  • 1247 posts

Posted 31 October 2011 - 04:31 PM

thanks :) it works
  • 0

#5 LOS.A

LOS.A

    GMC Member

  • GMC Member
  • 597 posts
  • Version:GM8

Posted 01 November 2011 - 02:27 PM

Are you sure it is completely accurate? I had some trouble with (2as = v^2 - v0^2) a while ago, and the people helping me concluded that it wasn't accurate because of the fact that time in GM isn't continuous (or lucid or whatever).
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users