Sign in to follow this  

Projectile position at specific time

Recommended Posts

Hey guys, i'm having a bit of a hard time finding the position of a projectile at a specific time.

I have a start point, a velocity, and some acceleration. I know the time that the projectile has been in motion, t and some distance let's say d.

Let's assume the distance is 20 and t is 0.5. In this scenario i want to find out where the projectile should be when it's 10 units from where it was shot off from.

I hope that makes sense....

I found this bit of code online, but i'm not sure how to actually plug my values in...

// Parabolic motion equation, y = p0 + v0*t + 1/2at^2
float ParabolicCurve(float p0, float v0, float a, float t) {
	return p0 + v0 * t + 0.5f * a * t * t;
}

Vector3 ParabolicCurve(Vector3 p0, Vector3 v0, Vector3 a, float t) {
	Vector3 ret = new Vector3();
	for (int x = 0; x < 3; x++)
		ret[x] = ParabolicCurve(p0[x], v0[x], a[x], t);
	return ret;
}

The problem i'm having is the above function works with respect to time. IE, if i want to find the position at a given distance instead of a given time....

Share this post


Link to post
Share on other sites

Your question kinda doesn't make sense. You're asking to solve for the position of a projectile a certain distance from an initial position..

But if you know the distance, then what are you solving for? (You already have the answer?)

The parabolic motion formula you pasted makes sense in terms of kinematics: you have an initial position; a velocity (change in position over time, or more accurately, change in displacement from the initial position over time); and acceleration (change in velocity over time, usually due to gravity and air resistance). The formula is given in terms of time because.. calculus.

But basically I'm not understanding your original question. Is the distance, d, that you're talking about, measured along the ground or something like that?  Or, is it measured along the curve itself?

Edited by masskonfuzion

Share this post


Link to post
Share on other sites

Distance is just velocity multiplied by time, so you can derive time from distance by dividing the distance by the velocity. That gives you a 't' value to plug in to the formula.

Share this post


Link to post
Share on other sites

I see. Is there a formula that would work given the desired height, distance and a value of t (between 0 and 1)? I assume this would need to figure out velocity and acceleration given the information and then plug those into the above formula?

Share this post


Link to post
Share on other sites

Yes, but now you are saying that you have a height/distance/time, that makes it sort of the opposite of your first question. Additionally, it depends on what you mean by height - you mean the y value returned for a given value of t, or do you mean the maximum height of the parabola?

Could you state your problem more precisely?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this