- Joined
- Mar 16, 2008
- Messages
- 941
Hi guys.
First of all, no I don't want to know how to stop a loop.
I have a small problem. I have a loop, thats creating four orbs.
I want those orbs to move from their position to a
location, but they had to fly in a curve. I had no idea
how to calculate a curve just with h as the maximum excursion
and the two points. While sitting in class today, it hit me.
My Problem is, that the functions I wrote seem to stop my loop...
the idea is this picture: (my programm had no brush for a curve xD)
ImageShack - Hosting :: blapm5.jpg
So the two points and h are given, I searched r.
So I calculated the distance and used the "highsentence" (in german: "Höhensatz", found no translation, sry^^).
It says: b² (half the distance) = h*rest, while the rest is 2*c+h, the point where r hits c is the middle of the line.
This is my loop:
Can anyone help me? I know that the loop "stops", because only one orb is created and the stuff after it isn't made, while it works without the if-condition. Btw, is the calculation for the angle right?
Sry for any mistakes in the text, I'm still learning English
Greets, Justify
First of all, no I don't want to know how to stop a loop.
I have a small problem. I have a loop, thats creating four orbs.
I want those orbs to move from their position to a
location, but they had to fly in a curve. I had no idea
how to calculate a curve just with h as the maximum excursion
and the two points. While sitting in class today, it hit me.
My Problem is, that the functions I wrote seem to stop my loop...
the idea is this picture: (my programm had no brush for a curve xD)
ImageShack - Hosting :: blapm5.jpg
So the two points and h are given, I searched r.
So I calculated the distance and used the "highsentence" (in german: "Höhensatz", found no translation, sry^^).
It says: b² (half the distance) = h*rest, while the rest is 2*c+h, the point where r hits c is the middle of the line.
This is my loop:
JASS:
//x and y are set outside ...
loop
exitwhen i>=4
set data2 = Orbs.create()
set ox = x+350*Cos((i*90+angle)*bj_DEGTORAD)
set oy = y+350*Sin((i*90+angle)*bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect("Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl", ox, oy))
set data2.orb = CreateUnit(Player(1), 'h002', ox, oy, 0)
set data2.tx = tx+i*40*Cos(i*70*bj_DEGTORAD)
set data2.ty = ty+i*40*Sin(i*70*bj_DEGTORAD)
set data2.lx = tx
set data2.ly = ty
if i <= 1 then
set data2.dist = FlightRadius(ox, oy, data2.tx, data2.ty, i*200)
set data2.angle = FlightAngle(ox, oy, data2.tx, data2.ty, i*200)
else
set data2.dist = FlightRadius(ox, oy, data2.tx, data2.ty, i*-200)
set data2.angle = FlightAngle(ox, oy, data2.tx, data2.ty, i*-200)
endif
set data2.height = 100*i+50
set OrbData[i] = data2
set i = i+1
endloop
JASS:
function FlightRadius takes real x, real y, real tx, real ty, real h returns real
local real b = 0.5*SquareRoot((x-tx)*(x-tx)+(y-ty)*(y-ty))
local real c = ((b*b)/h)+h
return SquareRoot(b*b+c*c)
endfunction
function FlightAngle takes real x, real y, real tx, real ty, real h returns real
local real b = 0.5*SquareRoot((x-tx)*(x-tx)+(y-ty)*(y-ty))
local real c = ((b*b)/h)+h
return Asin(SquareRoot(b*b+c*c)/(2*c+2*h))*bj_RADTODEG
endfunction
Can anyone help me? I know that the loop "stops", because only one orb is created and the stuff after it isn't made, while it works without the if-condition. Btw, is the calculation for the angle right?
Sry for any mistakes in the text, I'm still learning English
Greets, Justify
Last edited: