Find angle of a point from center of circle(从圆心找到一点的角度)
问题描述
如果我有一个像这样的图像 720、720..
If I have an image 720, 720 that looks like this..
如果中心 x 和 y 分别为 360、360,我如何计算所触摸的 x,y 的角度我看到的很多计算都假设原点是 0,0(左上角),所以我得到不正确的结果.我假设 0 总是在顶部而不是旋转.
How do I work out the angle of the touched x,y given that the center x and y are 360, 360 A lot of calculations I see for this assume the origin is 0,0 (which is top left) so I get incorrect results. I am assuming 0 is always to the top and not rotated.
推荐答案
这样可能更清楚:
(Math.toDegrees( Math.atan2(fromLeft - 360.0, 360.0 - fromTop) ) + 360.0) % 360.0
添加 360 度转弯并应用模运算符可以得到正角,而 atan2 没有.
Adding a 360 degree turn and applying the modulo operator gives you the positive angle, which atan2 does not.
这篇关于从圆心找到一点的角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从圆心找到一点的角度
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01