3D 数学:根据 Look 和 Up 正交向量计算倾斜(滚动)角度 [英] 3D Math: Calculate Bank (Roll) angle from Look and Up orthogonal vectors
问题描述
我希望这是问这个问题的正确位置,即 与此相同,但表示为纯数学而不是图形(至少我希望我将问题正确地转换为数学).
I hope this is the proper location to ask this question which is the same as this one, but expressed as pure math instead of graphically (at least I hope I translated the problem to math correctly).
考虑:
- 两个正交的向量:Up (ux, uy, uz) 和 Look (lx, ly, lz)
- 垂直于Look的平面P(因此包括Up)
- Y1 是 Y(垂直轴)沿 Look 到 P 的投影
问题:Y1 和 Up 之间的夹角是多少?
Question: what is the value of the angle between Y1 and Up?
正如数学家会同意的那样,这是一个非常基本的问题,但我已经挠头至少两个星期了,但无法想象如何将 Y 投影到 P 上……也许现在太老了,无法找到解决方案学校练习.
As mathematicians will agree, this is a very basic question, but I've been scratching my head for at least two weeks without being able to visualize how to project Y onto P... maybe now too old for finding solutions to school exercises.
我正在寻找三角解法,而不是使用矩阵的解法.谢谢.
I'm looking for the trigonometric solution, not a solution using a matrix. Thanks.
编辑:我发现我需要确定角度的符号,相对于必须是 Look 的旋转轴.我在我的链接问题上发布了最终代码(见上面的链接).感谢那些提供帮助的人.感谢您的时间.
Edit: I found that I needed to determine the sign of the angle, relative to a rotation axis which had to be Look. I posted the final code on my linked question (see link above). Thanks to those who helped. I appreciate your time.
推荐答案
我只是在纸上做这件事.我希望它是对的.
I'm just doing this on paper. I hope it's right.
假设 Up 和 Look 被归一化,即长度为 1.假设平面 P 包含原点,L 是其法线.Y 是 (0, 1, 0)
Let's assume Up and Look are normalized, that is, length 1. Let's say that plane P contains the origin, and L is its normal. Y is (0, 1, 0)
要将 Y 投影到 P 上,求它到 P 的距离...
To project Y onto P, find its distance to P...
d = Y dot L = ly
...然后通过 -d 缩放法线以获得 Y1(即 Y 在 P 上的投影)
...and then scale the normal by -d to get the Y1 (that is, the projection of Y on P)
Y1 = (lx * ly, ly * ly, lz * ly)
现在对 Y1 进行归一化,即按 (1/长度) 对其进行缩放.如果它的长度为 0,那么你就不走运了.
Now normalize Y1, that is, scale it by (1 / length). If its length was 0 then you're out of luck.
Y1 和 Up 的点积 = 角度的余弦.所以
The dot product of Y1 and Up = the cosine of the angle. So
angle = acos(Y1 dot Up)
这篇关于3D 数学:根据 Look 和 Up 正交向量计算倾斜(滚动)角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!