Question

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.

Était-ce utile?

La solution

angle = Math.atan2(dy,dx)

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

angle is in radians, dont forget to convert to degrees

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top