How do I Determine Which Direction to Rotate in a Circle

Get help using Construct 2

Post » Mon Feb 16, 2015 5:14 pm

I need the logic how to calculate to which direction my object need to turn, clockwise/counterclockwise in the most shortest angle distance to a destination in a circle.

Let me explain.
Let's say in a circle, my object is at 20degree, my destination is at 270 degree.
Calculating the shortest angle distance is easy.
AngleDistance1 = 270-20 =250 degree.
AngleDistance2 = 360-250 =110 degree.

Then I compare AngleDistance1 and 2. The smallest result is the shortest way.

But then I don't know how to calculate/determince, to which direction should my object turn.
Should it turn 110degree clockwise or counterclockwise. By seeing is easy to say turn CW or CCW, but without eyes and only numbers, how?

I need help on this.
B
10
S
5
Posts: 220
Reputation: 1,464

Post » Tue Feb 17, 2015 3:37 pm

In Construct 2 angles are calculated clockwise. At 0 degrees your sprite will be facing right, 180 degrees it will be facing left and 90 degrees it will be facing down etc. What this means is, if the angle you are turning toward is less than 180 degrees away, you would want to rotate clockwise. If it is more than 180 degrees, you would want to rotate counter clockwise. At exactly 180 degrees, it doesn't matter.
B
38
S
12
G
11
Posts: 329
Reputation: 7,708

Post » Wed Feb 18, 2015 1:44 am

Make sense. Thank you.
B
10
S
5
Posts: 220
Reputation: 1,464


Return to How do I....?

Who is online

Users browsing this forum: BinaryPanda, blackhornet, resdesign and 8 guests