• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Advanced maths: Z-angle for projectile. Smooth curve.

Status
Not open for further replies.

Cokemonkey11

Spell Reviewer
Level 30
Joined
May 9, 2006
Messages
3,537
JASS has no ^ operator
i think you mean Pow(a,p)
also most languages that do have an ^ operator it implements exclusive OR rather than exponentiation..

also..
does it have SquareRoot function? i would guess not ..
pow(a,0.5) is so trivial i dont see a reason for a separate square root function..

JNGP has a nice function library where u can look at all the built in functions, i would suggest to use it.

Because square root on floats is way cheaper than that.

http://betterexplained.com/articles/understanding-quakes-fast-inverse-square-root/
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Can anyone clarify what I am doing wrong?

JASS:
function GetPitch takes real speed, real gravity, real horizontal_distance, real vertical_distance returns real
    local real pitch = Atan((Pow(speed, 2) + SquareRoot(Pow(speed, 4) - gravity *(gravity * Pow(horizontal_distance, 2) + 2 * vertical_distance * Pow(speed, 2)))) / gravity)
    call BJDebugMsg("Pitch = " + R2S(pitch))
    return pitch
endfunction



function Trig_Test_Actions takes nothing returns nothing
    
    call GetPitch(50, 9.81, 100, 10)
    call GetPitch(100, 9.81, 100, -10)
    call GetPitch(50, 9.81, 300, -150)
    call GetPitch(400, 9.81, 300, 100)
    call GetPitch(100, 9.81, 1000, 10)
    call GetPitch(50, 9.81, 1000, 10)
    
endfunction

Response:
Pitch = 1.569
Pitch = 1.570
Pitch = 1.569
Pitch = 1.571
Pitch = 1.570
Pitch = 1.567

Can't be right.
 
Status
Not open for further replies.
Top