• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

Trigonometry Question

Status
Not open for further replies.
Level 11
Joined
Jan 23, 2015
Messages
788
Okay, I suck at math! I've learned a few things with War3 WE, but it's still not enough..

So, when I use the angle of two points for something, the max angle is 180, and when it passes 180 it returns 0.. How do I make the max angle 360 degrees?
 
Level 27
Joined
Sep 26, 2009
Messages
2,470
The function "angle between points" returns an angle in the interval (-180, 180], it basically looks like this:
Code:
          90
     135   |   45
180     -------      0
    -135   |  -45
         -90

Now the option here is to either use a sin/cos function which will convert it back and forth or do it manually by using calculation:
result = (angle + 360) % 360
Example inputs and outputs:
-180 + 360 = 180 ... 180 % 360 = 180.
90 + 360 = 450 ... 450 % 360 = 90

The % (modulo) operation gives as a result the remainder after diving one number by another. So the remainder in the calculation 450/360 is 90 - and that's the output of the modulo operation.
 
Status
Not open for further replies.
Top