• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Parabolic Formula

Status
Not open for further replies.
Level 18
Joined
Oct 18, 2007
Messages
930
Ok I need a quick awnser here for a parabolic arch formula. Nothing super fancy just a simple formula that can be excecuted in Jass/vJass.

Well offcourse you need some variables, here :
  1. Distance ( from the start to the end location )
  2. Time it takes
  3. Start X
  4. Start Y
  5. End X
  6. End Y
  7. Start Z
  8. End Z
  9. Interval ( Will excecute the code every x.xx seconds )
  10. Arch ( offcourse )

I kinda need 2 formulas that will interact with eachother.

I need a speed and height value to make this complete.

It will be used in a sort of "jump" or missile with arch spell.
And if you dont mind i would be glad if you all posted some Jass snipets with the formula.


For all you fancy guys out there that understand fancy formulas then please have a look here: "Clicky Clicky". I dont get it :p ( To many wierd letters and symbols :x )
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You do not need to include x and y into it? You run the Z separatly from them and simply move a unit in a line at a fixed rate.

You then use a formula that will make the unit fly up and then fly down by having something with a constantly decreasing gradient.

You could even do it by separating all the vectors completly and just using some value to syncronise them.

For the Z, you are after using the -x^2 as a base, as that is a perfect arch, althou it might not be easilly in that form, the equation for Z would be something like that.
You forgot to give us your syncronisy variable which is used to tell where it currently is on the arch.
 
Level 18
Joined
Oct 18, 2007
Messages
930
You forgot to give us your syncronisy variable which is used to tell where it currently is on the arch.[/QUOTE]

:p Sorry, i kinda dont know anything about theese formulas

You do not need to include x and y into it? You run the Z separatly from them and simply move a unit in a line at a fixed rate.

Ok ;)

You then use a formula that will make the unit fly up and then fly down by having something with a constantly decreasing gradient.

You could even do it by separating all the vectors completly and just using some value to syncronise them.

For the Z, you are after using the -x^2 as a base, as that is a perfect arch, althou it might not be easilly in that form, the equation for Z would be something like that.

Eh where does the contsant "Arch" come inn? So i can define how high/low it will be.

And that -x^2 is that -x•-x?

Please tell more. And could you give an example?
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
-x^2 = -(x . x)
(-x)^2 = (-x . -x)
but since multiplying 2 negative numbers is a positive number:
(-x)^2 = x^2 = NOT -x^2
if you want the minus to be counted with in the formula you have to set it between brackets, at least that is normal math,,
-x = -1 . x, so: -x^2 = -1 . x^2, that is why you should use brackets for parabolic formulas, if you want the minus to count in the formula,,

-Yixx,,-
 
Level 18
Joined
Oct 18, 2007
Messages
930
Well i've found this ParabolicZ formula on Wc3Campaigns.net .

It works but it has no curve relevance. It makes its own curve from the max height reached. Could someone look into it and make the returning height be depending on a cruve value from '0' and up? instead of having the parameter needing a height
 
Level 24
Joined
Jun 16, 2008
Messages
1,939
so if i understood u right, u want a formula that describes an arch?

k, lets see do it with a trigger or whatever running every 0.02 seconds

every 0.02 secs do:
if
h = desired height than do set h = h-1
elsedo
set h(height) = h+1
endif
set y(offset towards jumpdirection) = point offset by blah towards direction
move unit instantly
change unit flying height


for what do u n a formula?
 
Level 18
Joined
Oct 18, 2007
Messages
930
so if i understood u right, u want a formula that describes an arch?

k, lets see do it with a trigger or whatever running every 0.02 seconds

every 0.02 secs do:
if
h = desired height than do set h = h-1
elsedo
set h(height) = h+1
endif
set y(offset towards jumpdirection) = point offset by blah towards direction
move unit instantly
change unit flying height


for what do u n a formula?


Well it fails, because when it has reached it's desired height it will be set to the height -1 then it will be added one more time then it just loops :D

It would look like this
47817d1234379881-parabolic-formula-untitled.jpg


And this is a curve/arch
attachment.php
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    2.3 KB · Views: 278
  • Curve.jpg
    Curve.jpg
    3.3 KB · Views: 421
Level 24
Joined
Jun 16, 2008
Messages
1,939
First of all, because he can write in English.
As to your stupid "trigger", the height will just stay the same +-1 once it reaches the top. Very smart indeed.

ah nice to see u have a bad day...

right

sry ^^

hm rly ah parabola would be best, like -x^2 but it wont work cause it should be an upside down parabola which isnt infinite, right?

hm, i will think about it
 
Level 7
Joined
Jul 20, 2008
Messages
377
The way I would do it (because I'm lazy) is to implement acceleration by gravity. Have the Z velocity start out at a certain speed, and then have constant acceleration working to pull the Z velocity down (and even negative). This will produce a parabolic effect, and you can use kinematics to (on paper) calculate the distance the parabola would cover and the height, etc.

y = y0 + v0t + (1/2)at2
v2 = v02 + 2ay

and such...

You would just adjust the acceleration rate and the starting velocity.
 
Last edited:
Level 22
Joined
Dec 31, 2006
Messages
2,216
zvel = (gt) / 2
g = gravity (9.81)
t = time
Remember to decrease the zvel each interval by g * interval.
Arch could be added by changing the formula a little.
Like this:
zvel = (gat) / 2
a = arch
Reduce it by ga * interval.
This won't create a 100% correct arch, but it will work.
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
The_Reborn_Devil said:
zvel = (gt) / 2
... since when?

Look, here is EVERYTHING you might need to work this out, so pointed out by Soga- ( keep it up :D )

1) Δv = at
2) Δs = at2/2 + vit
3) vf2 - vi2 = 2aΔs
4) Δs = (vf + vi)Δt/2

There is absolutely nothing else you might need in this situation. See, I feel so nice that I"ll actually work it out for you.

So let's say you have 3 things defined: initial position, final position, and total time.
si denotes initial position
sf denotes final position
t denotes total time.

Thus, by the formulas written above:
Δs = at2/2 + vit
sf - si = at2/2 + vit
Since 'a' is a constant (-9.8 m/s2, not in Wc3 units) the only unknown is vi, initial Z velocity. So let's just isolate it then.
-at/2 + (sf - si)/t = vi

So that's your Z velocity. We know that Z velocity is the only one that varies (in a linear fashion), and XY velocity is constant, so, for XY:
Δs = vt
(sf - si)/t = v
Solve for X and Y in seperate dimensions, and then all you have to do is set that as an initial velocity to your object, and update acceleration on the z axis every interval.
 
Last edited:
Level 18
Joined
Oct 18, 2007
Messages
930
... since when?

Look, here is EVERYTHING you might need to work this out, so pointed out by Soga- ( keep it up :D )

1) Δv = at
2) Δs = at2/2 + vit
3) vf2 - vi2 = 2aΔs
4) Δs = (vf + vi)Δt/2

There is absolutely nothing else you might need in this situation. See, I feel so nice that I"ll actually work it out for you.

So let's say you have 3 things defined: initial position, final position, and total time.
si denotes initial position
sf denotes final position
t denotes total time.

Thus, by the formulas written above:
Δs = at2/2 + vit
sf - si = at2/2 + vit
Since 'a' is a constant (-9.8 m/s2, not in Wc3 units) the only unknown is vi, initial Z velocity. So let's just isolate it then.
-at + (sf - si)/t = vi

So that's your Z velocity. We know that Z velocity is the only one that varies (in a linear fashion), and XY velocity is constant, so, for XY:
Δs = vt
(sf - si)/t = v
Solve for X and Y in seperate dimensions, and then all you have to do is set that as an initial velocity to your object, and update acceleration on the z axis every interval.

Well, as o said. I do not understand those fancy symbols and calulations :p. Could you give a Jass example or how it will look?

Btw, all i wanted was a simple parabolic formula with arch. Or that takes an arch value
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
Okay. Here goes (written without an editor so there might be bugs)
JASS:
globals
    constant real g = -1000.0
    constant real FPS = 40.0
endglobals


struct object
    real xp
    real yp
    real zp
    real xv = 0.0
    real yv = 0.0
    real zv = 0.0
    // define more here...
    static method create takes real xpos, real ypos, real zpos returns object
         local object o = object.allocate()
         set o.xp = xpos
         set o.yp = ypos
         set o.zp = zpos
         // other stuff here...
         return o
    endmethod

    method projectToPointTimed takes real xPos, real yPos, real zPos, real time returns nothing
        set this.xv = (xPos - this.xp)/(time*FPS)
        set this.yv = (yPos - this.yp)/(time*FPS)
        set this.zv = (zPos - this.zp)/(time*FPS) - 0.5*g*time/FPS
    endmethod
endstruct

//... blahblah
function mainloop takes nothing returns nothing
    local object o
    // inside your main loop (that iterates every 1/FPS seconds)
        set o.zv = o.zv + g/(FPS*FPS)
        set o.xp = o.xp + o.xv
        set o.yp = o.yp + o.yv
        set o.zp = o.zp + o.zv
    // display the unit here with SetUnitX/Y and SetUnitFlyHeight etc...
endfunction
 
Level 4
Joined
Feb 2, 2009
Messages
71
Hmm. If you use flyheight, wouldn't the object act weird when moving over slopes/cliffs
I don't have any better option though, just wondering.

Haha, I can see Dynasti thinking "what have I gotten myself into". :D
I hope you'll HINDYhat's trigger.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
HINDYhat said:
The_Reborn_Devil said:
zvel = (gt) / 2
... since when?
HINDYhat said:
zv = (zPos - this.zp)/(time*FPS) - 0.5*g*time/FPS
That's the same, but it seemed like you were implying that it wouldn't work.
And shouldn't the "-" before the "0.5*g*time" be replaced by a "+"?
And the "+" here: o.zv + g/(FPS*FPS) should be replaced by a "-".
 
Level 18
Joined
Oct 18, 2007
Messages
930
Well Dynasti i'm not adverstising or anything But just try PALADONS JUMPS SPELL u will see a simpel so small formula that make an arch

Note : i'm not advertising it's up to u anyway I was just helping out ^^

That uses not an arch, but a height formula to create an arch. All I wanted to begin with is nothing fancy that uses gravity, velocity etc. Just a god damn simple arch formula like this:
JASS:
function Parablola takes real CurrentDist, real MaxDist, real arch returns real // Will return a height

Something like that. Please nothing more fancy, just something simple
 
Level 20
Joined
Apr 22, 2007
Messages
1,960
The_Reborn_Devil said:
That's the same, but it seemed like you were implying that it wouldn't work.
And shouldn't the "-" before the "0.5*g*time" be replaced by a "+"?
And the "+" here: o.zv + g/(FPS*FPS) should be replaced by a "-".
Please don't talk about what you don't understand. Just because I had a 0.5 in my equation, does not mean it equates to yours... at all. Mine makes sense, yours does not.

And no.

And no too.
 
Level 24
Joined
Jun 16, 2008
Messages
1,939
haha, i think i ve got a very easy solution using sin()

x in this case represents the angel

this is thre height formula:
sin(x) * maxheight

if u set x+1 in every interval u get a perfect arch whose height depends on length of the jump, means for ther maxrange that u move the unit for maxrange/180 every interval


if x is 180 then u turn the loop off and the unit should have reached 0 again.

if u dont understand what i mean u can write me a pm and i give u a gui version of the jump sys where i gona use this
 
Level 18
Joined
Oct 18, 2007
Messages
930
haha, i think i ve got a very easy solution using sin()

x in this case represents the angel

this is thre height formula:
sin(x) * maxheight

if u set x+1 in every interval u get a perfect arch whose height depends on length of the jump, means for ther maxrange that u move the unit for maxrange/180 every interval


if x is 180 then u turn the loop off and the unit should have reached 0 again.

if u dont understand what i mean u can write me a pm and i give u a gui version of the jump sys where i gona use this

OMG! FFS! Im tired of none reading the posts and just posting shit. I WANT AN ARCH!

Growing old of this! :/
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
I think I still did not understand what you really want. I think its the first function, but maybe you want to give the starting angle instead of the warcraft projectile arc (funciton 2 and 3).
JASS:
//like warcraft projectile-arc-value 
function ParabolaZ1 takes real arc, real d, real x returns real
  return (4 * arc) * (d - x) * (x / d)
endfunction

//angle for x == 0 (in Radians)
// @ requires -pi/2 < alpha < pi/2
function ParabolaZ2 takes real alpha, real d, real x returns real
  return - Tan(alpha)/d *x*x + Tan(alpha)*x
endfunction

//angle for x == 0 (in Degrees)
//@ requires -90 < alpha < 90
function ParabolaZ3 takes real alpha, real d, real x returns real
  return - Tan(alpha*bj_DEGTORAD)/d *x*x + Tan(alpha*bj_DEGTORAD)*x
endfunction
I did not test those functions in Warcraft but i think they are right.

If this is not what you want you could create a drawing to make it clear.
 

peq

peq

Level 6
Joined
May 13, 2007
Messages
171
Bet you 10$ that you did not read all the posts I have posted inn this thread.

Why is it so hard?!

I have read all of your posts (you may donate the 10$ to the hive :grin:). Its just that you want the function to take an arch and when i hear arch i think of a curve or something like this:
http://en.wikipedia.org/wiki/File:Rundbåge.png

But you want the arch to be a real and that confuses me (my english is not very good so maybe there is an other meaning i dont know).

And also:
Did you try the function of Palaslayer, HINDYhat or my function. I think they all generate archs. HINDYhat´s and mine are parabolic and Palaslayer´s has an other shape.
 
that was posted before, dumb one
Sry didn't see.

dunno why, but i made a demo map (not mui) of what i meant
though it is guy i expect you to be at least intelligent enough to use the same in jass, hope it helps
I may be dumb, but at least I am not a retarded idiot that sucks to the point of making something in GUI not MUI and then posting it like you did.

On the other hand, you may want to check how emilj3 makes arcs in his jump template.
 

Attachments

  • Jumping Spell Template v3.w3x
    72.8 KB · Views: 98
Level 7
Joined
Jul 20, 2008
Messages
377
Dynasti, do you just want the maximum height of the arc? Please be more specific than just saying you want "the arch." There are many properties of an arc, so which one are you looking for?

Usually, programmers perform parabolic effects in real time, as I do in my first post in this thread. Parabolas are rarely "pre-planned."
 
Level 18
Joined
Oct 18, 2007
Messages
930
Dynasti, do you just want the maximum height of the arc? Please be more specific than just saying you want "the arch." There are many properties of an arc, so which one are you looking for?

Usually, programmers perform parabolic effects in real time, as I do in my first post in this thread. Parabolas are rarely "pre-planned."

Ok i know there is alot of confusion.

You all know the arch height parabola function. The one that takes distance, current distance and height and returns a perfect arch height.

The one thing i want is that the height in the parameter is replaced with an arch value. So you can determine how sharp/dull the jumping arch will be.
 
did u recognize that i just posted it to make dynasti understand what i meant
Therefore I quote your avatar that describes you in perfection:
epic fail

u want the arch to be controllable? so e.g. a high jump with low range, or a long jump without much height?
Which is exactly what the Jump template I posted does ...
 
Level 6
Joined
Sep 5, 2007
Messages
264
In the formula to calculate max-height, couldn't you just use a factor of distance...
EG:
max-height = distance * factor, which would make the jump higher, the longer it has to go.
or
max-height = (max_distance - distance) * factor, which would make the jump higher, the less it has to go.
By "max-distance" I mean maximum casting distance.

You'd have to add a minimum value, of course... so that the "jump" can't have a height of 0, or just cap it to a minumum.
 
Status
Not open for further replies.
Top