# Angles

Status
Not open for further replies.

#### Magtheridon96

Level 36
To find the angle between two points (in radians), you could do:
Atan2(y-y0,x-x0)

But, is it ok if I do this:
Atan(y0-y/x0-x)

If yes, which is faster?

Last edited:

#### WaterKnight

Level 26
Tan is the reversion, taking an angle and returning you the associated ratio of lengths of opposite and adjacent side. Maybe you meant Atan, this should be faster but it is not exactly the same (see).

#### Magtheridon96

Level 36
Oh sorry, yeah I meant Atan

edit
Thanks for the link
Atan(1/0) returns a garbage value
Atan2 is safer (returning pi/2 with Atan2(1,0))

#### WaterKnight

Level 26
1/0 does not return anything because the code halts when encountering zero division.

#### HINDYhat

Level 20
Also, if you have an angle in the third or fourth quadrant, then your result will be messed up. e.g.:

Atan2(-1, -1) = -3pi/4
Atan(-1/-1) = Atan(1/1) = Atan2(1, 1) = pi/4

Status
Not open for further replies.

Replies
4
Views
884
Replies
1
Views
222
Replies
1
Views
592
Replies
1
Views
411
Replies
8
Views
25K