문제

Say a user clicks anywhere on the screen, I need to convert that point, say (500, 200), to a polar point from the center of the screen. The tap location (500, 200) is measured from top-left corner of screen.

So somehow, I have to convert from a cartesian system with its origin in the top-left of the screen to another cartesian system with its origin in the middle of the screen (width/2, height/2), and then that to a polar point from the center origin.

Another way of asking is I need the angle of a screen point from the center of the screen.

도움이 되었습니까?

해결책

angle = Math.atan2(dy,dx)

where dy = y2 - y1;
and dx = x2 - x1;

angle is in radians, dont forget to convert to degrees

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