求一条水平线旋转度数的方程

发布于 2024-12-02 19:17:08 字数 145 浏览 1 评论 0原文

嘿,所以我有一个对象的中心,我正在以该中心为起点绘制一条线,然后将鼠标定位到它的末端。

如何找到第二个点 (?,?) 围绕静止的第一个点 (0,0) 的旋转程度?
注意:如果第二个点是 (1, 0),它将旋转 0 度。

hey so I have a center of an object and i'm making a line with this center as the start of it, and the mouse position the end of it.

How do I find how rotated the second point (?,?) is around the stationary first point (0,0) ?
Note: if the second point were (1, 0) it would be roated 0 degrees.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等待圉鍢 2024-12-09 19:17:09

如果旋转角度为a,第二个点为(x,y),则:

a = arctan(y/x)

If the angle of rotation is a, and the second point is (x,y) then:

a = arctan(y/x)
梦初启 2024-12-09 19:17:08

还记得索卡托亚吗? ;) 您可以使用反正切(通过标准 atan2() 函数)来确定原点和任意点之间的直线的角度:

#include <cmath>

double mouseX = ...;
double mouseY = ...;
double angleInRadians = std::atan2(mouseY, mouseX);

Remember SOHCAHTOA? ;) You can use the arctangent (via the standard atan2() function) to determine the angle of the line between the origin and an arbitrary point:

#include <cmath>

double mouseX = ...;
double mouseY = ...;
double angleInRadians = std::atan2(mouseY, mouseX);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文