문제

I am looking for an algorithm to calculate the angle between two points (defined by x and y valaue) in an image. The angle should be between the horizontal-line of one of these points and the line that connects the two points.

How can I do that?

도움이 되었습니까?

해결책

For points (x1,y1) and (x2,y2) use this:

atan2(y2-y1,x2-x1)

This will return the angle between a horizontal vector from (x1,y1) to (x1+1,y1) and the vector from (x1,y1) to (x2,y2).

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