Why is −π < atan2(y, x) ≤ π while for lines we really need only from 0 to π? [duplicate]

StackOverflow https://stackoverflow.com/questions/4979631

  •  12-11-2019
  •  | 
  •  

문제

Possible Duplicate:
what is the difference between atan and atan2 in c++ ?

Why is −π < atan2(y, x) ≤ π while for lines we really need only from 0 to π and what has api like atan2 but would return from 0 to pi?

도움이 되었습니까?

해결책

One common application of atan2 is converting from cartesian coordinates to polar coordinates. And that it supports all angles is its reason of existance. Else you could just use atan(y/x).

다른 팁

atan2 returns all possible angles because it's not used just for drawing lines! It's used for actual maths as well, where the difference is important. atan, on the other hand, produces results in [-pi/2, +pi/2].

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top