• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Parabola in 3D

Status
Not open for further replies.
Level 13
Joined
Mar 29, 2012
Messages
542
parabola.png

How do I find the length of x and y?

I have a projectile that move by 30 on every iteration towards target but I want to apply that 30 to the parabola plane instead to the line straight to the target.

I used this function to make the arc projection:
JASS:
function Parabola takes real h, real d, real x returns real
    return (4. * h / d) * (d - x) * (x / d)
endfunction

// 'h' is the max height
// 'd' is the distance to target (max distance)
// 'x' is the currently traveled distance at the time when it is iterated

So it would be like this on every iteration:
JASS:
// --- Set projectile position + [speed] towards target

// --- Set projectile position (z) + Parabola([max height], [max distance], [traveled distance])
What can I do with these functions and variables to find the length of x and y?
 
Last edited:
You can set two variables to height as such:

Variable 1: height upwards
Variable 2: height downwards


Both need to run in the iteration for each 30 forward.

Variable 1 should be bigger initially with than variable 2, while variable 2 will exponentially increase with each iteration, so for example:

Set height for unit to (20+variable 1) at speed (your choice).
Wait.01
Set height for unit to (5+2*variable2) at speed (your choice)

Set variable 2= +2

You can either run this with the movement forward variable or have it triggered by the movement forward in a separate trigger. The variables will need to be adjusted number wise until you have found what you are looking for artistically. Variable 2 being a multiplier means that it will greatly affect the time at which the project will begin to descend. Set variable 1 as your control. Speed upwards will matter, so don’t be discouraged if you spend a good while finding the perfect balance.

To find X, you need to do real(distance between unit and the target unit). Set your firing unit as a unit variable and the target as a separate unit variable, and the third as the distance between unit 1 and unit 2. Then divide the third variable by 30, and set that as a real variable. That variable will be used in your iteration of 30 loop.
 
You can set two variables to height as such:

Variable 1: height upwards
Variable 2: height downwards


Both need to run in the iteration for each 30 forward.

Variable 1 should be bigger initially with than variable 2, while variable 2 will exponentially increase with each iteration, so for example:

Set height for unit to (20+variable 1) at speed (your choice).
Wait.01
Set height for unit to (5+2*variable2) at speed (your choice)

Set variable 2= +2

You can either run this with the movement forward variable or have it triggered by the movement forward in a separate trigger. The variables will need to be adjusted number wise until you have found what you are looking for artistically. Variable 2 being a multiplier means that it will greatly affect the time at which the project will begin to descend. Set variable 1 as your control. Speed upwards will matter, so don’t be discouraged if you spend a good while finding the perfect balance.

To find X, you need to do real(distance between unit and the target unit). Set your firing unit as a unit variable and the target as a separate unit variable, and the third as the distance between unit 1 and unit 2. Then divide the third variable by 30, and set that as a real variable. That variable will be used in your iteration of 30 loop.
What if I use the parabola function above?
I just updated the post, sorry for not mentioning it before.
 
I think it could work but you will need to repeat finding x for each iteration. Have the iteration find the distance laterally from the projectile to the unit and reset the x with the new coordinate.
 
You have some dx or dy (change in x and y) that you're using at each step of the iteration to move the point in a line across the ground. Every iteration you will move dl = Sqrt(dx^2 + dy^2) distance along; thus you need to compute that value one time and then keep track of the total distance you have traveled as L = L_prev + dl. Then use L in that formula where you have an x, h, d.
 
Every iteration you will move dl = Sqrt(dx^2 + dy^2) distance along; thus you need to compute that value one time and then keep track of the total distance you have traveled as L = L_prev + dl.
Yes, I did this.
Then use L in that formula where you have an x, h, d.
I don't understand this. :/

I wanted to move the projectile towards the target by x (on the image above), which is the x of the position change of the parabola line.
 
Last edited:
In your first post, you already created a correct formula to calculate the height of a point in a parabola according to how far you are from the point of origin:

View attachment 317241
JASS:
function Parabola takes real h, real d, real x returns real
    return (4. * h / d) * (d - x) * (x / d)
endfunction

// 'h' is the max height
// 'd' is the distance to target (max distance)
// 'x' is the currently traveled distance at the time when it is iterated

What pyrogasm is suggesting (which is, as usual, what you should do):

You have some dx or dy (change in x and y) that you're using at each step of the iteration to move the point in a line across the ground. Every iteration you will move dl = Sqrt(dx^2 + dy^2) distance along; thus you need to compute that value one time and then keep track of the total distance you have traveled as L = L_prev + dl. Then use L in that formula where you have an x, h, d.

is to calculate 'x' (the currently traveled distance at the time when it is iterated) by adding a fixed incremental number every iteration. So basically the 'x' you are looking for is L, which is incremented by dl in every iteration. Now, assuming the 'd' and 'h' values are fixed for your parabola (they should be), you can simply plug 'd', 'h' and 'L' (from pyrogasm's suggestion) into your formula, and get the height of the parabola in that point.
 
As far as I understand, you have these variables fixed for your projectiles:
  • Starting velocity (30)
  • Travel distance (h)
  • Maximum projectile height (d)
The variable you are looking for is:
  • Starting angle (or x and y, but same thing)
Unless you want to have a different gravitational acceleration for different projectiles, you cannot fix maximum height, because then you have overdefined the problem. The maximum projectile height needs to be a derived variable and cannot be constant.

You can derive the starting angle for a fixed starting velocity v, travel distance h, and gravitational acceleration g, and the x- and y-velocities with:

JASS:
set alpha = 0.5 * Asin(v*v / (2*g))
set vx = v * Cos(alpha)
set vy = v * Sin(alpha)

The coordinates x and y of the projectile at step t is then:

JASS:
set t = t + 1
set x = vx * t
set y = vy * t - 0.5*g*t*t
 
Last edited:
Thank you for sharing your thoughts. The solution for this problem is what Pyrogasm has said:
You have some dx or dy (change in x and y) that you're using at each step of the iteration to move the point in a line across the ground. Every iteration you will move dl = Sqrt(dx^2 + dy^2) distance along; thus you need to compute that value one time and then keep track of the total distance you have traveled as L = L_prev + dl. Then use L in that formula where you have an x, h, d.

Actually this is not really what I intend to find, but it is my mistake for making a wrong sketch of the actual problem I have. :(
Anyway, thanks.
 
Status
Not open for further replies.
Back
Top