围绕矢量旋转点(3D) [英] Rotate a point around a vector (3D)

查看:141
本文介绍了围绕矢量旋转点(3D)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我需要做的是围绕矢量旋转一个点.

我有向量x1 y1 z1和x2 y2 z2.我也有点x y z和旋转角度.

有谁能够帮助我?

谢谢

我尝试过的事情:

我正在尝试使用代码(http://blog.kjeldby.dk/wp-content/uploads/rotate.txt),但只有在度数设置为0时它才能正常工作,否则它会从任何逻辑中给出数字.

Hello,

what i need to do is to rotate a point around a vector.

i have the vector x1 y1 z1 and x2 y2 z2 . i also have the point x y z and the angle of rotation.

can anybody help me?

thank you

What I have tried:

i''m trying to use the code ( http://blog.kjeldby.dk/wp-content/uploads/rotate.txt ) but it works fine only when degrees is set to 0, otherwise it gives number out of any logic.

推荐答案

这不是很有效,但应该可以.您需要组成一个转换矩阵-一个3x3或-如果使用齐次坐标-一个4x4.

一种.要转换为(-x1,-y1,-z1)的矩阵,因此x1,y1,z1现在都为零.
b.矩阵以theta XZ旋转,使得(x2,y2,z2)现在位于YZ平面中(x2变为零).

您将需要记住一些几何来计算theta XZ.

C.矩阵旋转theta YZ使得(x2,y2,z2)现在是Z轴(x2和y2为零).

您将需要记住一些几何来计算theta YZ.

d.通过旋转角度绕Z轴(在XY平面中)旋转的矩阵.
e.应用上面(c)的逆.
F.应用上面(b)的逆.
G.应用上面(a)的逆.

您可以将上述矩阵连接成一个矩阵,并将其应用于您的点(x,y,z).如果使用4x4矩阵,请别忘了对结果进行归一化.
This isn''t terribly efficient but should work. You need to compose a transformation matrix - a 3x3 or - if using homogeneous coordinates - a 4x4.

a. matrix to translate to (-x1, -y1, -z1) so that x1,y1,z1 are now all zero.
b. matrix to rotate by theta XZ so that (x2,y2,z2) is now in the YZ plane (x2 becomes zero).

You will need to remember some geometry to calculate theta XZ.

c. matrix to rotate by theta YZ so that (x2,y2,z2) is now the Z axis (x2 and y2 are zero).

You will need to remember some geometry to calculate theta YZ.

d. matrix to rotate about the Z axis (in the XY plane) by your angle of rotation.
e. apply the inverse of (c) above.
f. apply the inverse of (b) above.
g. apply the inverse of (a) above.

You can concatenate the above matrices into a single matrix and apply that to your point (x,y,z). If using a 4x4 matrix, don''t forget to normalize the result.


最有可能是rad(0 ... 2pi)与度数(0.)的事物(混合). ..360)?

阅读此内容: Math.Cos-Methode :(双)(系统) [ ^ ]

特别说明:角度d必须为弧度.乘以Math.PI/180即可将度数转换为弧度.

这是什么意思:
Most probably a Thing (mix up) with rad (0...2pi) vs. degree (0...360)?

Read this: Math.Cos-Methode: (Double) (System)[^]

Especally Remarks: The angle, d, must be in radians. Multiply by Math.PI/180 to convert degrees to radians.

What does it mean:
// Degree will "fail", respectively not deliver the expected result
VectorMath :: Rotate(v, axis, 40.0)

vs.

// Rad should work
VectorMath :: Rotate(v, axis, 40.0 * Math.PI/180.0)



希望对您有所帮助.



Hope it helps.


这篇关于围绕矢量旋转点(3D)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆