# angle difference in both directions?

0 favourites
• 4 posts
From the Asset Store
Can you find all the differences? Find the differences before the time out. 10 levels for you to have fun!
• How do i get the difference between 2 angles both clockwise and counterclockwise?

I want to compare the 2 to test if it's quicker to rotate an object left or right from its current angle to its target angle in degrees.

I thought you could negate the anglediff expression but it still only calculates the shortest difference.

Thanks.

• This will give a signed angle diff between two angles.

angle(0,0,cos(a-b),sin(a-b))

It's in the range of -180 to 180. It always picks the shortest distance but it's negative if CCW and positive if CW.

Alternatively you could leverage the CW and CCW conditions or calculate if the angle diff is CW or CCW with

(sin(a-b)<0?-1:1)

global sign=1

global short_angdiff=0

global long_angdiff=0

every tick

--- set sign to (sin(a-b)<0?-1:1)

--- set short_angdiff to anglediff(a,b)*sign

--- set long_angdiff to (360-anglediff(a,b))*-1*sign

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Brilliant as always, thanks for your help.

• our R0J0hound is always there to help bless