HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Parabolic Function

08-15-2008, 12:51 PM#1
moyack
Collapse 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...

Collapse JASS:
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:

Zoom (requires log in)

_____________________________________________________________________


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

Jass function:
Collapse JASS:
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

Zoom (requires log in)

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.

Attached Images
File type: jpgGraphic1.jpg (18.8 KB)
08-15-2008, 01:32 PM#2
Vexorian
ok ...
08-15-2008, 01:55 PM#3
Rising_Dusk
Now this is cool.
08-21-2008, 02:31 PM#4
Spec
Hmm, I think this variant is less informative but it would be more efficient:
Collapse JASS:
function ParabolaZ takes real h, real d, real x returns real
  return h * (d - x) * x / d
endfunction
08-21-2008, 02:39 PM#5
moyack
This function does a parabola, but it doesn't fit with the condition of the max height.

In other words: if x = d/2 then ParabolaZ(x) != h
08-21-2008, 07:50 PM#6
emjlr3
very bad ass
08-22-2008, 07:48 AM#7
Spec
moyack, hmm, your function also doesn't fit that condition (or maybe I'm idiot?)
Quote:
h = 50
d = 50
x = 25

a = -4*50/(3*50*50) = -0,02(6)
b = 4*50/(3*50) = 1,(3)
result = a * 25*25 + b * 25 = -16,25 + 32,5 = 16,25

16,25 != 50
You need to fix the func:
Collapse JASS:
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
And also I fixed my variant:
Collapse JASS:
function ParabolaZ takes real h, real d, real x returns real
  return (4 * h / d) * (d - x) * (x / d)
endfunction
08-22-2008, 12:46 PM#8
moyack
You're fucking right, I've just checked my calculations and I miss a sign in the process.... definitely I have to sleep more often.

thank you very much for your comments.

+rep
08-27-2008, 04:32 PM#9
Drain Pipe
I did something similar a long time ago, you can see it from the link, but basically it does the exact same thing as this and it's what I've been using for about 3 years now, while I was coding using GUI

http://www.hiveworkshop.com/forums/f...formula-18324/

I think his is just broken up a little more, and in an actual function but if it does the trick, it's good.
08-27-2008, 05:33 PM#10
moyack
Quote:
Originally Posted by Drain Pipe
I did something similar a long time ago, you can see it from the link, but basically it does the exact same thing as this and it's what I've been using for about 3 years now, while I was coding using GUI

http://www.hiveworkshop.com/forums/f...formula-18324/

I think his is just broken up a little more, and in an actual function but if it does the trick, it's good.
Actually your formula is the same as this one, with the difference that this one is simplified in order to make it faster.
08-29-2008, 03:55 PM#11
Drain Pipe
Quote:
Originally Posted by moyack
Actually your formula is the same as this one, with the difference that this one is simplified in order to make it faster.

AND i did this 3 years ago. Seriously though, I wonder how he came up with this; I had tried for a long time to get this, but to no avail. It figured it out when I was screwing around with my calculator one day...
08-29-2008, 05:39 PM#12
Rising_Dusk
You can easily derive the formula in the first point by working backwards from the fundamental principles of kinematics with relation to the max height and max range formulas. You just have to assume the application of the parabola is for projectile motion is all, which is dead on with what it's generally used for.
08-29-2008, 06:32 PM#13
moyack
Quote:
Originally Posted by Dusky
You can easily derive the formula in the first point by working backwards from the fundamental principles of kinematics with relation to the max height and max range formulas. You just have to assume the application of the parabola is for projectile motion is all, which is dead on with what it's generally used for.
Nahhh, I did it in a simpler way, with zero derivatives and zero kinematics. I just based in the fact that this kind of movement is always a parabola (unless wind and other external factors interfere in the situation of course), therefore a parabola function can be used perfectly.

I came to this result as follows:

H(x) = parabolic function
D = Max dist that the parabolic movement must move
h = Max height that the parabolic should achieve

(1) H(x) = Ax^2 + Bx + C
(2) H(0) = 0 => A0^2 + B0 + C = 0 => C=0
(3) H(D) = 0 => AD^2 + BD = 0 => B=-AD
(4) H(D/2) = h => A(D/2)^2 + B(D/2) = h


Let's replace B in the equation (4) with the result obtained in (3) and we'll obtain the following:

(5) A(D/2)^2 - AD(D/2) = h => A(D^2/4) - AD^2/2 = h => A(D^2/4) - 2(AD^2/4) = h => -(AD^2/4) = h => A= -4h/D^2

Now let's replace in the result obtained in equation (3) the value of A and we'll obtain the value of B:

B=-AD => B=-(-4h/D^2)*D => B= 4h/D

Now, just replace the values of A and B in the parabolic function and voila!! let's play with our function.
08-29-2008, 06:39 PM#14
Rising_Dusk
Clever thought process, I would've approached it from a physics standpoint since that's how I work, but okay. <3
08-29-2008, 06:53 PM#15
blu_da_noob
Very much a school way of solving it :P
Given three points on a parabola, find the equation of the parabola. Physics principles would probably be less work though.