# Make system expression angle(x1,y1,x2,y2) to return 0-360?

Get help using Construct 2

### » Tue Mar 03, 2015 3:36 pm

As angle system expression returns value 0 to 180 then -180 to 0 clockwise. How to make it return 0-360 instead ?
B
5
Posts: 16
Reputation: 259

### » Tue Mar 03, 2015 3:49 pm

You can use conditionals, but the expression usually comes out fine math wise.
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211

### » Tue Mar 03, 2015 4:04 pm

If you need 0-360 for purposes of comparisons, etc., it can be normalized from 0-360 using:
(Angle % 360 + 360) % 360
B
31
S
7
G
8
Posts: 232
Reputation: 6,294

### » Tue Mar 03, 2015 4:47 pm

Thanks, that works! I don't know why it work...Can you give me the direction where to study "%" operation like that. My highschool math class does not have thing like that.
B
5
Posts: 16
Reputation: 259

### » Tue Mar 03, 2015 7:11 pm

It shouldn't matter if you do your math right. All angular operations should be cyclical so it doesn't matter if it returns -180 to 180 or 0 to 360. (Unless you display the result to the user.)
Scirra Founder
B
414
S
245
G
92
Posts: 25,188
Reputation: 200,307

### » Tue Mar 03, 2015 7:42 pm

I use angle to drive animation frame so i want full absolute 360 degree.
B
5
Posts: 16
Reputation: 259

### » Tue Mar 03, 2015 8:42 pm

The % is the modulo operator. It gets the division remainder between two numbers.
For example: 375 % 360 = 15, 360 % 360 = 0, 90 % 360 = 90, etc.

Step 1: Angle % 360
Single angle could be negative or positive, the first modulo returns a remainder between -359 to +359 degrees.
Returns the positive quadrant equivalent: (ex: -90 degrees would be pointing upward, this returns 270 degrees)
Step 3: % 360
If original angle was positive, step 2 would have caused it to exceed 360 degrees, so take the modulo again.

B
31
S
7
G
8
Posts: 232
Reputation: 6,294

### » Tue Mar 03, 2015 9:15 pm

Thank you very much ,now this modulo thing make sense to me.
B
5
Posts: 16
Reputation: 259

### » Tue Mar 03, 2015 9:29 pm

Thats actually a little scary. Hope you don't use 360 frames.
B
178
S
50
G
205
Posts: 8,684
Reputation: 127,211