以弧度计算一个点绕另一点的旋转

发布于 2024-10-12 01:43:52 字数 229 浏览 2 评论 0原文

我一周来一直在努力解决这个问题,并找到了解决方案。我所拥有的是二维空间中的 2 个点,我需要解决的是其中一个点围绕另一个点的旋转。幸运的是,附图会有所帮助,我需要能够计算的是 b 绕 a 的旋转值。

alt text

我发现了很多指向寻找点积等的东西,但我仍在寻找那个黄金解决方案:哦(

谢谢!

I have been trying to get this problem resolved for week and have get to come to a solution. What I have is 2 points in a 2d space, what I need to resolve is what the rotation of one is around the other. With luck the attached diagram will help, what I need to be able to calculate is the rotational value of b around a.

alt text

I have found lots of stuff that points to finding the dot product etc but I am still searching for that golden solution :o(

Thanks!

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

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

发布评论

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

评论(3

韵柒 2024-10-19 01:43:52
Vector2 difference = pointB - pointA;

double rotationInRadians = Math.Atan2(difference.Y, difference.X);

请参阅 http://msdn.microsoft.com/en-us/ Library/system.math.atan2.aspx 供参考。

Vector2 difference = pointB - pointA;

double rotationInRadians = Math.Atan2(difference.Y, difference.X);

See http://msdn.microsoft.com/en-us/library/system.math.atan2.aspx for reference.

筱果果 2024-10-19 01:43:52

猜测:

  • 1.) 求直线 A、B 的斜率 m。
  • 2.) 将斜率转换为角度 theta = arctan(m)
  • 3.) 将角度投影到以 A 点为中心的笛卡尔坐标系中的象限,得到归一化角度

A guess:

  • 1.) Find the slope m of the line A, B.
  • 2.) Convert slope to angle theta = arctan(m)
  • 3.) Project the angle to a quadrant in a cartesian coordinate system centered at point A to get the normalized angle
少女的英雄梦 2024-10-19 01:43:52

我假设正东(沿 X 轴向右)的弧度为零,+x 指向右侧,+y 指向下方。

B 相对于 A 的方位角为

angle = Arctan2 [(A_y - B_y) / (B_x - A_x)]

使用适当的函数计算适当的象限(可能是 Math.Atan2

I'll assume that due east (along the X axis, to the right) is zero radians, and that +x points to the right and +y points down.

The bearing of B with respect to A is

angle = Arctan2 [(A_y - B_y) / (B_x - A_x)]

Use the proper function to calculate the proper quadrant (probably Math.Atan2)

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