**Category:** Geometry

**Language:** vJASS

Parabolic function simplified by Spec

library ParabolicMovement

function ParabolaZ takes real h, real d, real x returns real

return (4 * h / d) * (d - x) * (x / d)

endfunction

endlibrary

I left this function because it allows to understand the formula coefficients...

function ParabolicMovement takes real h, real d, real x returns real

local real a = -4*h/(d*d)

local real b = 4*h/d

return a*x*x + b*x

endfunction

This function takes as a parameters the distance that the parabolic movement should move (d) and the maximum height the projectile will flight (h).

So x is a value between 0 and d, and the function will return the height for that value.

As a side note, if x < 0 or x > d then this function will return negative values.

Here's a picture for a better understanding of the parameters:

_____________________________________________________________________

Parabolic movement now taking into account initial and final Z heights.

library ParabolicMovement2

function ParabolaZ2 takes real y0, real y1, real h, real d, real x returns real

local real A = (2*(y0+y1)-4*h)/(d*d)

local real B = (y1-y0-A*d*d)/d

return A*x*x + B*x + y0

endfunction

endlibrary

Notes:

- This function will return the absolute height and therefore this value should be the height you must set to the unit in the function SetUnitFlyHeight()-y0.
- In order to obtain a proper parabolic shape, "h" must be greater or equal than the maximum value of "y0" and "y1", but anyways, you're free to play with lower values of "h". "h" is the height when x = d/2 but it's not necessarily the maximum height it will reach, the maximum height will be reached when x = -B/2A.