• 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.

[JASS] Function not working properly

Status
Not open for further replies.
Hello,

I have just recently learned JASS and wanted to make a function that calculates an angle with an arcustangent function. this is the function:

JASS:
function arcustangent takes real G, real A returns real
    if ( A < 0 ) then
        return AtanBJ( G / A ) + 180
        elseif ( A == 0 ) then
            if ( G > 0 ) then
                return AtanBJ( G / ( A + 0.01 ) )
            else
                return AtanBJ( G / ( A - 0.01 ) )
            endif
        else
        return AtanBJ( G / A )
        endif                
endfunction

later in the script, the variable declaration and function call:

JASS:
function fastcalculation takes nothing returns nothing
...
...     
    local real A
    local real G
...
...
        set G = ScalarSpeedFrontVtF - ScalarSpeedVertBack
        set A = ScalarSpeedFrontPtF - ScalarSpeedParaBack
        set udg_ScalarMA[i] = arcustangent( G, A )

The values for G and A (Adjacent and Opposite) are not being handled by the arcustangent function. i just substituted the equation with set G = 5 and set A = 1, to see if this is the problem, but it didnt change anything. So the equation is NOT the problem. the function always returns zero (as the arcustangent of zero is zero).

Im completly new to JASS, so i dont know if I made any syntax errors. Jasscraft and the World Editor did not spit out any errors.
 
Level 9
Joined
Nov 28, 2008
Messages
704
It works by putting the angle in the correct quadrant. Also, it requires radians, and you were using AtanBJ which uses degrees. Could be why yours wasnt working.
 
Status
Not open for further replies.
Top