• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Simple Question

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
  • Set r = (Angle from TempLoc to TempLoc2)
How to change that to JASS by using pure coordinates ?
Basically I want the r value to be calculated by using pure coordinates instead of locations.

I tried the Atan2 functions before and failed (maybe I was doing it incorrectly) and I know this is such a simple question for vJASS-er, thank you.

Tried this but I'm sure this is wrong lol:
  • Custom script: set dx = GetUnitX(udg_u2) - GetUnitX(udg_u1)
  • Custom script: set dy = GetUnitY(udg_u2) - GetUnitY(udg_u1)
  • Custom script: set udg_r = SquareRoot((dx*dx) + (dy*dy))
 
JASS:
function AngleBetweenPoints takes location locA, location locB returns real
    return bj_RADTODEG * Atan2(GetLocationY(locB) - GetLocationY(locA), GetLocationX(locB) - GetLocationX(locA))
endfunction

So..
JASS:
    set udg_r = bj_RADTODEG * Atan2(dy, dx)

You can skip the bj_RADTODEG * if you don't want to convert to degrees and use radians instead.
 
Status
Not open for further replies.
Back
Top