Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在处理在我的程序中使用的通用旋转功能。我使用 atan2(y, x) 函数来获取角度。由于原点位于我的 Nexus S 的左上角,我实际上使用 atan2(-y, x) 在 atan2 中获得正确的结果。否则我会得到错误的旋转方向。例如,从 P0(5,1) 移动到 P1(1, 5) 在我的机器人中是顺时针方向,而在正常象限中是逆时针方向。
我的假设是所有安卓设备的原点都在左上角。这是正确的吗?
是的,原点总是在屏幕空间的左上角。这是有历史原因的,因为屏幕空间计算是在电视机用作屏幕时开始的。电视的光栅枪从左上角开始,所以这被认为是原点。
该规则有一些值得注意的例外(尽管不适用于 android 设备) - 可可界面似乎起源于左下角。