# Trigonometry Question

Status
Not open for further replies.

#### RobertMKD

Level 11
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?

#### Nichilus

Level 27
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.

#### RobertMKD

Level 11
Okay, thanks I've made this and it works:

Angle between Point1 and Point2 + 180

and it works just as i want it to..

Status
Not open for further replies.

Replies
3
Views
737
Replies
2
Views
677
Replies
6
Views
1K
[vJASS] Angle Finding
Replies
11
Views
1K
Replies
5
Views
440