Calculate throw angle to have the curve cross a certain point

In summary, KiririA suggests that you use the equation s = at2 + ut + c to solve for the position and velocity of a leaping object. You also need to know the time to hit the target and the magnitude of the velocity.
  • #1
kiriri
6
0
Hello,
I'm not sure if this is the right section because this is somewhat of a hybrid of math and physics.
Say I have a ball in 3D space, its initial position and its' initial acceleration. Furthermore I have another point in 3D space which I want the ball to pass through, if possible. The gravity is 9.81 m/s2. Friction etc is of no importance.
How could I calculate the initial angle or tangent of this curve, so that the ball would hit the point , if possible?

In case that just now wasn't all that clear, I'll explain my problem in my current context. I'm a game developer and want players to be able to click at a point and jump to it the next time they hit space. However, they can charge their jump and if they are very close to the target and have charged up the jump a lot they must jump in a high arc to hit the target sqarely. If the target is too far away, the player should jump using 45%, but I can program by comparing the distance. All I need is a formula which takes the initial acceleration and the gravity and calculates which angle is needed to hit that point

I'm sorry to bother you guys with such a simple question, but I really wasn't able to find a solution on my own.

best,
kiriri
 
Last edited:
Physics news on Phys.org
  • #2
A bouncing object in general takes the form of an inverse parabola, and that is what games use nowadays for the jumping animation. The speed of the person while traveling in the parabolic shape can be given by another parabola, because the person starts out traveling fast, reaches its slowest and stops for a moment when he/she reaches the vertex of the parabola in the air and then starts accelerating again. Given that we take the parabola to be quadratic, there will be no problems with positiveness of distance and speed.

Of course, you will need to determine a realistic vertex for the parabola, for to determine a parabola 2 points are not enough (the starting point and the terminating point.) The further you want to jump, the less you will go into the air. You need to determine also a realistic range for the person to jump. When you do determine this radius, try to meet the condition I specified. I do have something in mind but there are a lot of other alternatives, and you can't know which is the most sensible without testing (which I can't).
 
  • #3
Hey kiriri and welcome to the forums.

For this problem, you can use the equation s = at2 + ut + c, but in the direction of your velocity and acceleration vectors which will be parrallel to each other.

The first thing is that c will be the position (which is a vector) that corresponds to the balls position before it takes off. The a will be an acceleration vector corresponding to the force on the object when in free-fall which is going to be 9.8m/s in the direction that you decide for gravity (so probably -z direction in most 3D worlds, but it depends on what you use).

The u vector is your velocity vector that you have to figure it in terms of the angle, and also with regard to finding the actual point.

So here is the basic idea, what you do is you solve what is known as a boundary problem. You have a point of intersection that you want to to hit at t = t'. Don't worry about what this is at the moment, but what you have is that at some point in the future the s' for a given t' is equal to the point in space that you want the ball to hit.

So here is what you know: you know s' (future point of ball to hit), you know s0, a, and probably ||u|| (the length of the velocity vector but not its direction), and you want to find the direction of u.

If you know the time you want it to hit (in terms of time after the player launches or the ball launches), then you plug in this t' into the equation to solve for the vector u by solving:

ut' = s' - at'2 - c where c is the initial launch spot, t' is the time elapsed (in seconds) after hitting the object and u is what you need to figure out. This is just substituting in the vectors a, s', c and the scalar quantity t'.

If you have information about the magnitude of the velocity, then you get the equations:

u^t' = (at'2 - c)/||u|| where ||u|| is the magnitude of the velocity the moment the leap is made.

Again though, you still have a free parameter corresponding to the time it takes to get to the point and you will have to figure this out, and it will depend on your game code. For example you can aim really high and reach the mark on the way down or you can reach the point on the way up, depending on the requirements.

The thing that you will have to factor in is the geometry surrounding the spot you wish to get: for example if you have say a solid ring surrounding the object, then you won't be able to do a steep angle shot because it would collide with the ring.

So the first thing you need to do is to do some raycasting from the point of interest between the angles corresponding to the ray from the point of interest to point of leap all the way to the maximum position at the peak of the jump corresponding to a 45 degree leap (which is a maximum).

Once you do these casts you will narrow down the possible solutions to for the leap and then you can use any such solution to construct a tangent vector condition which when worked backwards will give you a way to find the initial u vector.

I know this is probably not clear as it could be so please clarify anything that needs to be made clearer by myself.
 
  • #4
wow, I wouldn't have thought I'd find other game makers here :D
I think I now see that time is an essential part and I think I've managed to create some very close approximations based on delta y and delta x compared to the x speed and max x speed. I can't finish it until I have the jump tangent implemented, but I think this just might be possible :)

Thank you chiro for your elaborate explanation. However, I fear you were right, I really don't understand all of it, no matter how hard I try to :S .
Basically I can't comprehend how you got from
ut' = s' - at'2 - c
to
u^t' = (at'2 - c)/||u||
?
How can s' be of no importance in the second formula? and why has ut' become ut'?
 
Last edited:
  • #5
kiriri said:
wow, I wouldn't have thought I'd find other game makers here :D
I think I now see that time is an essential part and I think I've managed to create some very close approximations based on delta y and delta x compared to the x speed and max x speed. I can't finish it until I have the jump tangent implemented, but I think this just might be possible :)

Thank you chiro for your elaborate explanation. However, I fear you were right, I really don't understand all of it, no matter how hard I try to :S .
Basically I can't comprehend how you got from

to

?
How can s' be of no importance in the second formula? and why has ut' become ut'?

Sorry kiriri there was a mistake. It should be

s = 1/2at2 + ut + c
s' = 1/2at'2 + ut' + c and in terms of having a magnitude of velocity:

u^t = [s - 1/2at'2 - c]/||u|| where ||u|| is the magnitude, and u^ is a direction vector. Use those equations instead with the 1/2 (and with the s included) instead of the other ones. You can derive them from integrating constant acceleration up to displacement by using initial conditions for velocity and displacement.

I'm happy to go through the details though: it's not as hard as it first seems in terms of this formula: the hard part is using the geometry of the world and your game variables to come up with the right possible ways of doing so. For example if something was in a tube, then the only way you can get it is to go completely horizontal parallel to the surface of the cylinder, but if the thing was in open space, then you could approach it from many points.

If you think about specific questions that will help you implement this, I'll do the best I can to help you (and also FYI I used to do game design myself).
 
  • #6
Have you looked in a physics text at the chapter on projectile motion ?
 
  • #7
There is acceleration, of value -g, vertically so, taking y as the height, v as the initial speed, (x_0, y_0) as the initial point, and [itex]\theta[/itex] is the angle of elevation at which is is projected, you have
[itex]y= (a/2)t^2+ vcos(\theta)t+ y_0[/itex]
and
[itex]x= vsin(\theta)+ x_0[/itex]

Setting those equal to the (x, y) coordinates of the point you want to hit gives you two equations to solve for t and [itex]\theta[/b]. Notice that the equation for y is quadratic. There will, in general, be two different angles at which you could "fire" and hit the target. Of course, there might be no real solution- if you are trying to hit a target beyond your range.
 
  • #8
HallsofIvy said:
There is acceleration, of value -g, vertically so, taking y as the height, v as the initial speed, (x_0, y_0) as the initial point, and [itex]\theta[/itex] is the angle of elevation at which is is projected, you have
[itex]y= (a/2)t^2+ vcos(\theta)t+ y_0[/itex]
and
[itex]x= vsin(\theta)+ x_0[/itex]

Setting those equal to the (x, y) coordinates of the point you want to hit gives you two equations to solve for t and [itex]\theta[/b]. Notice that the equation for y is quadratic. There will, in general, be two different angles at which you could "fire" and hit the target. Of course, there might be no real solution- if you are trying to hit a target beyond your range.

That is not the only problem though: as pointed out, certain geometry may in fact yield no solutions to the target even being hit, even if the quadratic does have one or more solutions.
 
  • #9
The delayed reply is from moving. Can you get at this angle with these equations
from projectile motion :
x/(t)(v0) = cos theta

y + 1/2gt2 /(v0)(t) = sin theta

From x = (vo cos theta)t
y = ( v0 sin theta) t - 1/2gt2
at any time t
 

Related to Calculate throw angle to have the curve cross a certain point

1. How do I calculate the throw angle to have the curve cross a certain point?

The throw angle can be calculated using the formula:
θ = tan-1((2h-gd2)/(2d))
Where:
θ = throw angle
h = height of the desired point
g = gravitational acceleration (usually 9.8 m/s2)
d = distance to the desired point

2. What is the importance of calculating the throw angle for a curve?

Calculating the throw angle allows you to accurately aim an object to hit a specific target. This is important in sports such as baseball, where the pitcher needs to throw the ball at a certain angle to make it cross the home plate, or in engineering where objects need to be launched at precise angles to reach their desired destination.

3. Can the throw angle be calculated for any curve?

Yes, the throw angle can be calculated for any curve as long as the necessary information such as height, distance, and gravitational acceleration are known.

4. Is there a specific unit of measurement for the throw angle?

The throw angle is typically measured in degrees, but it can also be measured in radians. It is important to use consistent units throughout the calculation.

5. Are there any factors that can affect the accuracy of the calculated throw angle?

Yes, factors such as air resistance, wind speed, and release point can affect the accuracy of the calculated throw angle. These factors should be taken into consideration when making the calculation and adjustments may need to be made to compensate for them.

Similar threads

Replies
3
Views
442
Replies
21
Views
1K
  • Special and General Relativity
Replies
17
Views
1K
  • Introductory Physics Homework Help
2
Replies
39
Views
2K
  • Introductory Physics Homework Help
2
Replies
38
Views
2K
Replies
2
Views
1K
Replies
14
Views
1K
  • Introductory Physics Homework Help
5
Replies
157
Views
7K
  • Introductory Physics Homework Help
Replies
7
Views
1K
Back
Top