Warcraft 3 documentation
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

[Snippet] Parabolic Function No New Posts Codes & Snippets

Started by

0 Members and 1 Guest are viewing this topic.

[Snippet] Parabolic Function
on: January 12, 2012, 09:00:58 PM
Category: Geometry
Language: vJASS

Parabolic function simplified by Spec
Code: jass
  1. library ParabolicMovement
  3. function ParabolaZ takes real h, real d, real x returns real
  4.   return (4 * h / d) * (d - x) * (x / d)
  5. endfunction
  7. endlibrary

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

Code: jass
  1. function ParabolicMovement takes real h, real d, real x returns real
  2.     local real a = -4*h/(d*d)
  3.     local real b = 4*h/d
  4.     return a*x*x + b*x
  5. 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.

Code: jass
  1. library ParabolicMovement2
  3. function ParabolaZ2 takes real y0, real y1, real h, real d, real x returns real
  4.   local real A = (2*(y0+y1)-4*h)/(d*d)
  5.   local real B = (y1-y0-A*d*d)/d
  6.   return A*x*x + B*x + y0
  7. endfunction
  9. endlibrary

  • 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.
« Last Edit: December 18, 2017, 06:18:12 AM by moyack »

Re: [Snippet] Parabolic Function
Reply #1 on: January 13, 2012, 12:11:45 PM

Nice :D

I love simple libraries like these. :)


Started by moyack

Replies: 3
Views: 4325

Started by Magtheridon96

Replies: 8
Views: 16525
Jass Tutorials

Started by Jedi

Replies: 5
Views: 14906
General Jass Discussion

Started by rvonsonsnadtz

Replies: 10
Views: 21422
Coding Help
Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   Power of Corruption, an altered melee featuring Naga and Demon. Play it now!!!   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod   WormTastic Clan (wTc)   Warcraft RESOURCES Reforged: Modelos, mapas, proyectos y mas...