Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

ryanalex

Predicting jump trajectories...

This topic is 5759 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Thanks for the help! I''m trying to have a char jump (can be considered a particle) and hit a goal position. how can I find the initial impulse vector which will land the char on a certain point? ie: char position = vector(10,10,0) goal position = vector(100,0, 100) how do find the impulse or initial velocity? thanks!

Share this post


Link to post
Share on other sites
Advertisement
s = s0 + v0t + (1/2)gt2
v = v0 + gt

Let s = the goal position.
s0 is the initial position.
v0 is the initial velocity (for which you are solving)
g is the gravitational constant, about 9.81 m/sec
2 on Earth
t is time

It looks like there''s one too many variables. Not true. Set v=0 in the second equation to find the time it will take to reach the top of the arc. Then find the time it will take to fall back down using the same equation in reverse. (Or if it''s a level surface, just find t once and multiply by two). Once you know t, you know everything except v in the top equation. Solve.

I understand that it''s not quite as simple as this. There are an infinite many values of v that will work. So add one more equation to this system of equations:

|v0| = k
Or, in other words,
v.x02 + v.y02 + v.z02 = k2)


Even with this restriction, there will be two possible answers in most cases: A high arc or a long, low jump.

It''ll take a while to work all these equations out, but it''s nothing you can''t do now that you have them.

Share this post


Link to post
Share on other sites
Thanks for the help!

Would it make it simpler if I had a constant jump angle or a constant length for the jump velocity?

What would the equation be in that case?

Share this post


Link to post
Share on other sites
I think it would be easier to specify a time that you wish it to take rather than an original velocity, that's just my opinion, although it might not necessarily be permissible in your case.

It would be a little trickier if you wanted it to go through a specific angle, I'd stick with velocities if I were you, or as I suggested, the time you want it to take.

just offering another point of view.

Elijah

in response to your last post, v0 is the original velocity and v is the function v(t) which is the velocity at every instant t.

[edited by - etaylor27 on September 12, 2002 5:00:48 PM]

Share this post


Link to post
Share on other sites
Hi sorry. I know It''s not a very straightforward problem to solve, but I''m still not sure how to solve for the initial velocity. i know there can be many answers, so how what do i need to know to solve for only one? Supposing I knew the time it should take to reach the goal. is there a simpler way to make a rough estimate?

Share this post


Link to post
Share on other sites
you might like to look at this thread:

http://www.gamedev.net/community/forums/topic.asp?topic_id=107074

it was "what is the launch angle if the x/y/z distances and the launch vel are known"

hope it helps
fatray

Share this post


Link to post
Share on other sites
Let's keep things simple for starters. In your first post you give an example in 3D, which is quite possible to solve with all of the equations presented, but more difficult as now we have to work with a vector representing the x-axis (y-axis is the same as it's still "up and down").

To extensively paraphrase the posted link, you have two different velocities to find - an x velocity and a y velocity, which can be resolved into an angle and speed if you wish, but isn't necessary for the math. Now, in order to solve for these velocities, you need to know how long the projectile should take to get "there" (as well at what "there" is). Otherwise, there are just about an infinite number of solutions.

First we solve for the y velocity, as it is the most complicated one. Considering "the equation" (-(1/2)gt2 blah blah ), we can solve for v0, because we know all the other information. I won't perform the algebraic manipulation to isolate v0, not because it's too hard, but because it would be a pain in the ass trying to format it and display it to the page (without making use of the ugly negative exponents ). So we solve that, and we have v0. Yippy.

Next comes the trusty x velocity. This one isn't in the least bit difficult. We have our goal x distance, and the time it should take to reach that x. We have distance and time. Velocity = Distance / Time. Man, it doesn't get much sweeter

So now you have the x and y velocities. You can really do whatever you want with them now, whether it involves finding the speed of the projectile or it's launch angle, or actually using the velocities to model the projectile, tehe

And now to go back and address of the issue of working in 3D. Basically, simple trajectory modeling is a 2D "thing". When you move it into 3D, you can think of the modeling as taking place in a plane. If you set up your system right, the plane can be perpendicular to the XY axis and y velocity calculations (which are really Z values in 3D) can remain as simple as stated in my third paragraph. However, now we have to deal with our "x-axis" (the 2D modelilng axis, in other words - I will use quotes from now on), which can actually be aligned in any direction on the XY plane, giving it 3D x and y components. So say our projectile starts at (0,0,0) and wishes to magically fire itself at (10,-10,10). From a bird's eye view above, looking in the direction of the -Z axis, we can see our "x-axis" direction is at a 45 degree angle to the +X axis. This means that our "x-axis" vector (normalized) is (0.707,-0.707,0), which is correct, as it should be coplanar with the XY axis (no Z value in other words). So, whenever we wish to find the real x and y components of our object using the 2D "x-axis" as our modeling tool, we multiply this normalized vector by our speed, and then by the time. To simplify the operation, you can chose not to normalize our "x-axis" vector, but give it x and y components of it's own that reflect the x and y velocities of the projectile, respectively. That way the speed is already incorporated into the vector.

Hope that was all clear. The last paragraph was a long shot, but I hope I did a good job explaining it

[edited by - Zipster on September 14, 2002 4:05:01 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by ryanalex
Would it make it simpler if I had a constant jump angle or a constant length for the jump velocity?



Whoops, I should have explained that last part better. k is that constant jump magnitude.

Share this post


Link to post
Share on other sites
I read the post that FatRay posted a link to. It seems like they've solved the problem, and terranFury's solution seems like it would work, given the constant magnitude.

This is the equation posted in the other thread:
tan a = [u +/- (u2 - 2g(y + 1/2g(x2/u2)))1/2] / [gx/u]

It finds the angle of the velocity.

What I'm still unsure about is how these equations translate into C style code. Especially the one above. And TerranFury, could you maybe explain how your equation on top fits with the |v0| = k restriction? Sorry guys. I know i'll get this i'm just pretty bad at translating formulas into code.

Edit: Oops, forgot. Would it be simpler to translate the coordinates to an arbitrary plane as Zipster suggests? I'm still looking over your post, Zipster. Are all of these equations under that assumption, or is it possible to solve this in true 3d?

[edited by - ryanalex on September 16, 2002 3:38:30 PM]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!