Change the zero angle of the atan2() or similar
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I have a group of points in an image and I want to order them/get properties in a clockwise direction. The condition to order them will be their angle.
I need to choose the starting point, with angle 0, and then the other points in a clockwise order (increasing angle). However, I am using the atan2 (2 because the range of angles in better) to get the angles, but the zero angle is always in the horizontal axis. How can I set the axis of the zero angle to be in the location of the starting point?
Many thanks! Hector
댓글 수: 1
Muthu Annamalai
2013년 9월 18일
As @John points out, adding a post-atan2 offset should do the trick, and give you what you're looking for.
답변 (3개)
John Petersen
2013년 9월 18일
Add an offset to the angle. Let the offset be the starting angle.
댓글 수: 0
Roger Stafford
2013년 9월 18일
If you want the order to be clockwise and if (x0,y0) is the start point then do this:
ang = mod(atan2(y0,x0)-atan2(y,x),2*pi);
where (x,y) are the points to be ordered - they can be vectors. These angles will be in radians. The subtraction is necessary because the natural order in 'atan2' is counterclockwise. The 'mod' function is necessary to ensure that the range of 'ang' remains between 0 and 2*pi.
댓글 수: 0
theodore panagos
2019년 1월 15일
The formula give a clockwise angle, from 0 to 2pi.
f(x,y)=pi()/2*((1+sign(y0))* (1-sign(x0^2))-(1+sign(y))* (1-sign(x^2)))+pi()/4*((2+sign(y0))*sign(x0)-(2+sign(y))*sign(x))
+sign(x0*y0)*atan((abs(y0)-abs(x0))/(abs(y0)+abs(x0)))-sign(x*y)*atan((abs(y)-abs(x))/(abs(y)+abs(x)))
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!