• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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))
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
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.
Top