How do I use Angle?

Get help using Construct 2

Post » Mon May 09, 2016 5:43 am

Hi,

According to the manual:
https://www.scirra.com/manual/126/system-expressions

"...Angles start with 0 degrees facing right and increment clockwise."
"angle(x1, y1, x2, y2) Calculate angle between two points"

From that I assume 90 degrees is down, 180 degrees is left and 270 degrees is up.

So why does angle(100,100, 0, 0) return -135?

Shouldn't it be either 225 or 45? What does the negative number indicate?

Regards, John
B
17
S
5
G
2
Posts: 14
Reputation: 2,042

Post » Mon May 09, 2016 6:13 am

B
69
S
40
G
24
Posts: 356
Reputation: 18,314

Post » Mon May 09, 2016 11:16 am

This is the exact post by R0J0hound that explains it:

R0J0hound wrote:It's a mathimatical reason. The angle() function uses atan() to do the calculation, which has a range of [-180,180). Also that range is often referred to as a normalized angle and is usuful at times. Having the angle in the range of [0,360) is mainly useful in the case you stated above, and I usually convert it over in a expression with:
(angle(x1,y1,x2,y2)+360)%360

expression-returns-negative-angles_p1034161?#p1034161
B
125
S
43
G
41
Posts: 849
Reputation: 28,260


Return to How do I....?

Who is online

Users browsing this forum: TheCrazyPrince and 18 guests