【问题标题】:Converting a screen tap location to a polar point from screen's center将屏幕点击位置转换为屏幕中心的极点
【发布时间】:2013-07-09 20:41:19
【问题描述】:

假设用户点击屏幕上的任意位置,我需要将该点(例如 (500, 200))转换为屏幕中心的极点。点击位置(500、200)是从屏幕的左上角开始测量的。

所以不知何故,我必须将原点位于屏幕左上角的笛卡尔系统转换为原点位于屏幕中间(宽度/2,高度/2)的另一个笛卡尔系统,然后从中心原点到极点。

另一种询问方式是我需要屏幕点与屏幕中心的角度。

【问题讨论】:

标签: math transformation polar-coordinates cartesian-coordinates


【解决方案1】:
angle = Math.atan2(dy,dx)

其中 dy = y2 - y1;
和 dx = x2 - x1;

角度是弧度,别忘了转换成度数

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-06
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多