# How does "Clockwise from angle" work?

Discussion and feedback on Construct 2

### » Fri Jul 22, 2016 12:50 am

So this isn't really a problem per se, just wondering if I'm understanding this condition correctly. The way I took it, if angle X is closer to angle Y measuring clockwise, then it's true. Consequently, the inverse of this condition tests if angle X is closer counterclockwise. Manual seemingly confirms this.

Anyway, I was using these conditions to make a sprite play different animations when it's clockwise/counterclockwise from another object, and it basically did what I wanted it to except that the conditions registered as exact opposites to what I expected. In other words, when the Sprite was facing upward and had the Object at around its 3 o'clock, it registered it as counterclockwise. When it had it around 9 o'clock, it registered it as clockwise.

Of course the solution was to simply switch the conditions, but now I'm wondering if I'm understanding these conditions correctly.
B
65
S
25
G
19
Posts: 307
Reputation: 14,041

### » Fri Jul 22, 2016 1:37 am

Clockwise means it's a greater angle. 45 degrees is clockwise of 0 degrees. 45 degrees is counterclockwise of 90 degrees.
It's the direction the clock hands move.
B
179
S
50
G
207
Posts: 8,719
Reputation: 128,306

### » Fri Jul 22, 2016 9:59 am

If you are looking for the smallest difference between two angles, just if, then use this expression:

anglediff(angle 1, angle 2)
B
33
S
18
G
29
Posts: 2,493
Reputation: 21,450

### » Fri Jul 22, 2016 6:49 pm

On second thought it might not have been the fault of the conditions but the input. The angle I was testing was between two objects, i.e. angle(x1, y1, x2, y2), so perhaps it was testing the angle from the target object to the sprite, thus giving me inverse results. That'd make sense, heh.

Anyway, thanks for the replies y'all.
B
65
S
25
G
19
Posts: 307
Reputation: 14,041