There are point A (origin) and point B (target). And also there is gravity vector G. I need compute initial velocity of projectile (throwing arc trajectory from point A to point B).

Also I need to control speed of projectile (Speed) and flexion of throwing arc.

How compute this?

  • \$\begingroup\$ This is fairly complicated math, what should it be used for? Do you really have to know the initial force to hit the target exactly? If not then just cheat by trying out til you find homemade numbers that 'just works' \$\endgroup\$ – Valmond Dec 13 '16 at 9:16
  • \$\begingroup\$ @Valmond I need to shoot from weapon (point A) with non-linear (arc) projectile directly to target (point B, considering the obstacles). Projectile spawned with specified initial velocity and gravity, but not moving to point B. I want correct trajectory by target. \$\endgroup\$ – Broly Dec 13 '16 at 9:21

Assume your variables are: initial velocity v_0 = (v_0_x, v_0_y, v_0_z), initial position p_0 = (p_0_x, p_0_y, p_0_z), and target position p_t = (p_t_x, p_t_y, p_t_z).

First, choose your initial y-velocity, and calculate the time it requires to reach its target on the y-axis using this equation:

t =  \frac{-v_0_y \pm \sqrt{v_0_y^{2} - 2(p_0_y - p_t_y)g}}{g}

If you want the projectile to reach its target while it's ascending, choose the plus sign, otherwise, choose the minus sign. (Note that gravity, g, should be < 0).

Now you can calculate the initial x-velocity by using this equation:

v_0_x = \frac{p_t_x - p_0_x}{t}

Likewise, for the initial z-velocity:

v_0_z = \frac{p_t_z - p_0_z}{t}

You can modify the curve of the arc by changing the initial y-velocity.

| improve this answer | |
  • \$\begingroup\$ +1 Good one! I think I misunderstood the question, if I compare our answers. \$\endgroup\$ – Artery Dec 13 '16 at 9:52
  • \$\begingroup\$ media.giphy.com/media/l0MYuhmyKQYzYHY4g/source.gif But I got some calculation error between point B and actual point of arc collision. Whats wrong? \$\endgroup\$ – Broly Dec 13 '16 at 13:08
  • \$\begingroup\$ Can you please tell me what values you chose? \$\endgroup\$ – WindyKeeper Dec 14 '16 at 8:54

Depending on how accurate you need to be and how much processing power you what to use for this, you could compute the position and speed of your projectile by using the semi-explicit euler:

Semi-explicit euler:

First calculate the new velocity:

  • v(t + h, p(t)) = v(t, p(t)) - h*g

Than you calculate the new position:

  • p(t + h) = p(t) + h*v(t + h, p(t))


  • v is velocity-vector
  • t is your current time
  • h is your timestep (e.g. 1 if you calculate every second)
  • p(t) is the current position at time t
  • g is your gravity

Depending on your context and actual needs you can calculate the flexion of this as well, because you have a specific amount of concrete points of your throwing arc.

Please mind the semi-explicit euler is not the most accurate one, but pretty fast and not so difficult to implement.

| improve this answer | |
  • \$\begingroup\$ In my context time is does not matter. I can't insert t to computations, I have only coords of start and end positions. \$\endgroup\$ – Broly Dec 13 '16 at 9:43
  • \$\begingroup\$ Instead of time you can use just a counter for iteration steps, wouldn't matter at all. \$\endgroup\$ – Artery Dec 13 '16 at 9:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.