# How to find initial velocity with fixed angle of projectile

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

## Recommended Posts

Hello guys im new here.

Im making a game like gunbound or worms, and i need help to make computer hit the target with wind force.

My plan is to use a fixed angle, and to find initial velocity to launch the projectile.

I found this equation but it works without wind:

'L' = distance X from the target and 'h'=distance Y

Anyone know similar equation that works with wind force?

Sry my english.

##### Share on other sites
It depends on how exactly you have implemented your "wind force".

##### Share on other sites
I implemented wind like acceleration X and Y every frame i increment on velocity X and Y.

##### Share on other sites

I implemented wind like acceleration X and Y every frame i increment on velocity X and Y.

That just has the same effect as gravity, then. You can just add the two together, define "down" to be the direction in which that vector points and use the same formula you would have used without wind.

Let me point out that your wind will probably feel wrong, because that's not at all what wind does to things. A better model would have drag, and the wind is used at the point where you compute the velocity of your object with respect to the air. If the drag is linear, you can still solve the resulting differential equations analytically and get a closed formula. But perhaps you should start thinking about numerical methods that are much more flexible.

##### Share on other sites
Here's something along the lines of what alvaro is suggesting (in terms of a better model)...

Your projective has state (x,v), where x is its position vector and v is its velocity vector. Letting m be its mass, c a drag coefficient, and u(x) the wind velocity at position x, a reasonable model is,

dx/dt = v
dv/dt = (1/m)*(m g + c ||u(x)-v||(u(x) - v)) .

which I will write compactly as,

dx/dt = v
dv/dt = f(x,v) .

A simple and effective way to integrate this is to choose a fixed timestep dt and run,

x[sub]k+1[/sub] = x[sub]k[/sub] + v[sub]k[/sub] dt
v[sub]k+1[/sub] = v[sub]k[/sub] + f(v[sub]k[/sub], x[sub]k+1[/sub]) dt

which is the Symplectic Euler method.

##### Share on other sites

[quote name='Zrymer' timestamp='1305048516' post='4809039']
I implemented wind like acceleration X and Y every frame i increment on velocity X and Y.

That just has the same effect as gravity, then. You can just add the two together, define "down" to be the direction in which that vector points and use the same formula you would have used without wind.

Let me point out that your wind will probably feel wrong, because that's not at all what wind does to things. A better model would have drag, and the wind is used at the point where you compute the velocity of your object with respect to the air. If the drag is linear, you can still solve the resulting differential equations analytically and get a closed formula. But perhaps you should start thinking about numerical methods that are much more flexible.
[/quote]

Ok with wind accelaration Y i can sum with gravity acceleration, but about acceleration X i dont know what to do.

##### Share on other sites
Acceleration is a vector. Add gravity and wind to find the total acceleration. Now you can change coordinates so the acceleration's direction is "down" and you can use whatever formula worked before you had wind.

##### Share on other sites
Change the acceleration direction to "down"..... it dont make sense. its only make gravity acceleration bigger.

##### Share on other sites
Or just use an iterative solver: guess the result then check if it's valid (the distance of the desired point and the calculated point is smaller than a small value), if not: refine the guess.

It would be easier for us to help if you showed how you calculate the position from the angle and the velocity (which is a fishy term anyway. Velocity is a vector, so the angle is redundant here. I guess you meant speed, which is the length of the velocity vector.)

##### Share on other sites

Or just use an iterative solver: guess the result then check if it's valid (the distance of the desired point and the calculated point is smaller than a small value), if not: refine the guess.

It would be easier for us to help if you showed how you calculate the position from the angle and the velocity (which is a fishy term anyway. Velocity is a vector, so the angle is redundant here. I guess you meant speed, which is the length of the velocity vector.)

Exactly, the equation that i got is to find speed, and i use cos and sin to get vector from speed.
I will try to find any formula that work directly with vectors, i guess it will be easier than work with angles.

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633728
• Total Posts
3013577
×