2025年物体围绕某个点旋转一定角度

物体围绕某个点旋转一定角度2D 上的点围绕某另一个点旋转 If you rotate point px py around point ox oy by angle theta you ll get p x cos theta px ox sin theta py oy ox p y sin theta

大家好,我是讯享网,很高兴认识大家。

2D上的点围绕某另一个点旋转: If you rotate point (px, py) around point (ox, oy) by angle theta you’ll get:

p'x = cos(theta) * (px-ox) - sin(theta) * (py-oy) + ox p'y = sin(theta) * (px-ox) + cos(theta) * (py-oy) + oy 

讯享网

this is an easy way to rotate a point in 2D.

=======================================http://stackoverflow.com/questions//rotate-a-3d-point-around-another-one Try to use vector math. decide in which order you rotate, first along x, then along y perhaps.

If you rotate along z, [z’ = z]

讯享网x' = x*cos a - y*sin a; y' = x*sin a + y*cos a; The same repeated for y-axis: [y'' = y'] x'' = x'*cos b - z' * sin b; z'' = z'*sin b + x' * cos b; Again rotating along x-axis: [x''' = x''] y''' = y'' * cos c - z'' * sin c z''' = z'' * sin c + y'' * cos c 

And finally the question of rotating around some specific “point”:

First subtract the point from the coordinates, then apply the rotations and finally add the point back to the result.


讯享网

The problem, as far as I see, is a close relative to “gimbal lock”. The angle w_ny can’t be measured relative to the fixed xyz -coordinate system, but to the coordinate system that is rotated by applying the angle w_nx.

As kakTuZ observed, your code converts point to spherical coordinates. There’s nothing inherently wrong with that – with longitude and latitude one can reach all the places in Earth. And if one doesn’t care about tilting the Earth equatorial plane relative to it’s trajectory around the Sun, it’s ok with me.

The result of not rotating the next reference axis along the first w_ny is that two points that are 1 km a part of each other at equator, move closer each other at the poles and at latitude of 90 degrees, they touch. Even though the apparent purpose is to keep them 1 km apart where ever they are rotated.

================================== UE4中的实现方式

FVector A; FVector B; FRotator C; 

A点绕B点旋转C之后的坐标:

讯享网B+C.RotateVector(A-B)
小讯
上一篇 2025-02-20 23:00
下一篇 2025-01-19 09:14

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/77955.html