• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

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 24
Joined
Sep 26, 2009
Messages
2,320
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