Warcraft III resources & community, 2003–2006 · archived

IsAngleBetweenAngles

not rated
Submitted by AltSubmitterCalculations0 downloads
Compares whether a angle is between 2 angles. Most useful when you want to get a sector area.
The MaxAngle is specified to be larger than the MinAngle.
Ex:
IsAngleBetweenAngles(10, 5, 60 ) => true
IsAngleBetweenAngles(80, 10, -10 ) <=> AngleBetweenAngles(80, 10, 350 ) => true
Note: The function ignored max = min (always returns false) deal, because something like IsAngleBetweenAngles(X, Y,Y ) is meaningless. So it will always return true if the min = max (counts as 0~360).

Source

function IsAngleBetweenAngles takes real MatchingAngle, real MaxAngle, real MinAngle returns boolean
    if ( ModuloReal(MaxAngle-MinAngle,360) == 0.0 ) then
        return true
    endif
    if ( ModuloReal(MaxAngle-MinAngle,360) > 180.0 ) then
        return ( (ModuloReal(MaxAngle-MatchingAngle,360) <= 180.0) or (ModuloReal(MatchingAngle-MinAngle,360) <= 180.0) )
    endif
    return ( (ModuloReal(MaxAngle-MatchingAngle,360) <= 180.0) and (ModuloReal(MatchingAngle-MinAngle,360) <= 180.0) )
endfunction

Comments

0

No comments.