HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Moving in an Arc without Trigonometry

07-09-2007, 06:54 PM#1
TheSecretArts
I think ive found i nice, non memory taxing way of moving units in a arc without trigonometry and still imposing gravity and drag and such... it might not be super effective but it works, at least when i graphed it... please, check my work to see if its some dumb fantasy idea.

Variables:
IFv='Z' Force
Fh='XY' Force
IH=Initial Height
Fg=Gravimetric Force
Fd=Drag Force
T= Time Elapsed per 'step'
X= 'Steps' run
Calculations Run Per Step:
Fv = IH+((((IFv-Fg*X)X)-Fg*X)*T)
Fh = Fh-Fd


Example Function:
Collapse JASS:
function Move takes real height, real horforce, real vertforce, real steptime, unit u returns nothing
         local real IFv = vertforce
         local real IH = height
         local integer X = 0
         local real T = steptime
         local real Fh = horforce
         set Fv= IH+((((IFv-Fg()*X)X)-Fg()*X)*T) //Fd() and Fg() are imaginary functions that return gravity force and drag force
         set Fh=Fh-Fd()
         call SetUnitFlyHeight(u,Fv)
         //Set Unit XY code, im to lazy to write it out
         set X=X+1
endfunction
And this could easily be modified to work with structs and such so it could be handled with timers... but im not going to get into that detail here.
07-09-2007, 07:00 PM#2
Captain Griffen
Learn to use JASS tags.

Additionally, trig functions are lightning fast. Faster than an empty function call.
07-09-2007, 07:02 PM#3
TheSecretArts
err... i was editing the post to use JASS tags and add /remove content... and trig functions get slow when called every .01 seconds for over a few seconds
07-09-2007, 07:26 PM#4
Toadcop
Quote:
Additionally, trig functions are lightning fast. Faster than an empty function call.
O_O what does it mean !? example please... cause i don't understand what you mean...
Quote:
trig functions are lightning fast
well in any case it's not faster than to set a variable ^^ and to call empty func is maybe 2x slower.(not more !)
// btw who cares ^^
07-09-2007, 07:48 PM#5
Captain Griffen
Trig functions don't get slower. They are a very very fast lookup table.
07-09-2007, 07:55 PM#6
moyack
This is a post that I did at the Hive, which was useless because the requesters wanted only GUI (meh!!) probably it can be useful for you TheSecretArts.

Quote:
Originally Posted by moyack at the hive
Let's do a customizable parabolic equation, so you can develop a function to do that.

a parabolic function can be written in this way: y = ax^2+bx+c

so we need to know the values of a, b and c. How can we do that?? easy, let's see the initial conditions:

d = horizontal distance that the projectile should move.
h = maximum parabola height

x = 0; ax^2+bx+c = 0
x = d/2; ax^2+bx+c = h
x = d; ax^2+bx+c = 0

replacing in the equations the x value, we will obtain this:

a*0 + b*0 + c = 0 => c = 0
a*(d^2/4)+b*d/2 = h
a*d^2+b*d= 0


With the last two equations we can get a and b in terms of h and d, which are the known values. I did the calculations and the result are:
  • a = (-4*h)/(3*d^2)
  • b = (4*h)/(3*d)

now with that, we can do a function in JASS which calculates the height of the projectile in function of the maximum height and distance advanced in this way:

Collapse JASS:
function ParabolicMovement takes real h, real d, real x returns real
    // h, d, and x are in the same units of distance in WC3, which is more comfortable to use :)
    local real a = -4*h/(3*d*d)
    local real b = 4*h/(3*d)
    return a*x*x + b*x
endfunction

I hope this can help you with your spell. God bless math!!!
07-09-2007, 08:08 PM#7
Toadcop
Quote:
Trig functions don't get slower. They are a very very fast lookup table.
%) well i can't tell anything cause i don't see any logic. but never mind ^^ (the lookup table is a shit for children in jass native operations are never drop performance ! i have tested it for some one like you so you could see what 10K of globals vars don't matters ! or i got only 2 global vars or 10-20K makes no performance differrence) but you can live in your theory world.
07-09-2007, 08:37 PM#8
TheSecretArts
Instead of parabolic equation, just write Quadratic... and im going to condese my declaration to a quadratic, because it can be condesed... i implemented this system in my Spell Entry #9... well... it actually doesnt do quadratic math but i am unable to update it but it arcs the way it should be... but it does create nice arcs that actually work if your not looking for perfection