- Joined
- May 20, 2009
- Messages
- 822
I'm curious. Has anyone tried this, yet?
Well, both ways gave me the same results. Pitch is limited, raging from -180 to 0 (in radians, ofc). I noticed if you assign other values to it, the orientation is displayed in a glitchy way as you said.Did you use set pitch roll & yaw,
or did you use set oriantation (all at once).
I observered that setPitch flips the facing (forward, backwards) of the effect if it jumps over ~1.6, ~4.8 which can produce quite wierd results, arrows looking in 2 directions if you fastly bounce over that values.
SetOriantation does not have this behaviour.
-Cos(angle) * slope
for Pitch, and Sin(angle) * slope
for Yaw.// Function shamelessly extracted from wurst math lib
// Credits to BlinkyBoy, I guess?
function SlopeAngle takes real z1, real z2, real dist returns real
return Atan2(z2 - z1, dist)
endfunction
function SetEffectAngle takes effect whichEffect, real angle, real slope returns nothing
// Yaw, Pitch, Roll
call BlzSetSpecialEffectOrientation(whichEffect, Sin(angle) * slope, -Cos(angle) * slope, angle)
endfunction
call SetEffectAngle(whichEffect, angle, SlopeAngle(whichEffects_Height, anotherHeight, distance))
struct MissileVector3
real x
real y
real z
//yaw
//zero safety in case of y==0 or (y==0 and x==0)
method operator angleX takes nothing returns real
local real ix = RAbsBJ(this.x)
local real iy = RAbsBJ(this.y)
return Atan(this.z/this.y)*(1-(ix/(ix+iy)))
endmethod
//pitch
//zero safety in case of x==0 or (x==0 and y==0)
method operator angleY takes nothing returns real
local real ix = RAbsBJ(this.x)
local real iy = RAbsBJ(this.y)
return -Atan(this.z/this.x)*(1-(iy/(ix+iy)))//the - is not a mistake
endmethod
//roll
method operator angleZ takes nothing returns real
return Atan2(this.y,this.x)
endmethod
endstruct