Calculating the angle between the line defined by two points

前端 未结 6 1127
我在风中等你
我在风中等你 2020-11-28 08:17

I\'m currently developing a simple 2D game for Android. I have a stationary object that\'s situated in the center of the screen and I\'m trying to get that object to rotate

6条回答
  •  有刺的猬
    2020-11-28 08:37

    "the origin is at the top-left of the screen and the Y-Coordinate increases going down, while the X-Coordinate increases to the right like normal. I guess my question becomes, do I have to convert the screen coordinates to Cartesian coordinates before applying the above formula?"

    If you were calculating the angle using Cartesian coordinates, and both points were in quadrant 1 (where x>0 and y>0), the situation would be identical to screen pixel coordinates (except for the upside-down-Y thing. If you negate Y to get it right-side up, it becomes quadrant 4...). Converting screen pixel coordinates to Cartesian doesnt really change the angle.

提交回复
热议问题