旋转相机与旋转场景点(只有点,而不是整个场景)有什么不同? [英] Different between rotating the camera vs rotating the scene point (only the point, not the entire scene)?
问题描述
我认为旋转相机并拍摄场景的照片会产生相同的结果,保持相机稳定并以相反的方式旋转场景。
假设原始相机旋转矩阵是R1。旋转相机意味着我们应用另一个旋转矩阵R12(因此R2 = R12 * R1是新的旋转矩阵)。假设X是场景点的真实坐标。以相反方式旋转场景点意味着我们将反向旋转矩阵R12 ^ -1应用于X(这可能是错误的)。
那么为什么(R12 * R1 )!= R1 (R12 ^ -1 * X)?
任何人都可以解释我' m错了?
ps我并不是在问这两种方法的复杂程度。我只想知道
(1)动作的数学方程式旋转场景
( 2)如果我假设的旋转场景方程是正确的,那么为什么数学方程不能像我所描述的那样反映现实世界中的现象。
编辑1 :根据 Spektre 的回答,当我用旋转矩阵R旋转整个场景时,新的相机旋转矩阵为
R ^ -1 * R1
在这种情况下,我用旋转矩阵R12 ^ -1旋转整个场景,然后新的相机旋转矩阵是
( R12 ^ -1)^ - 1 * R1 = R12 * R1
但是,如果我考虑到旋转相机相当于旋转场景点X(仅场景点X,而不是整个场景)。那时,相机的旋转矩阵仍然是R1。但现场点X现在变成X'。 X'的图像坐标是R1 * X'。 X'的等式是什么?请注意,
R1 * X'= R12 * R1 * X
当然,您可以回答
X'= R1 ^ -1 * R12 * R1 * X
但我认为X'只能由R12和X来定义(R1不需要知道形成X')。这就是为什么我问旋转场景点的数学公式是什么。 X'是通过与R12相关的某个旋转矩阵的旋转X动作的结果。
pre $ code> [R1-R1 *(C + d)] * X = [R1-R1 *在上面的等式中(我检查是正确的),-R1(R)= 1, * C是平移矢量,-R1 *(C + d)是我向右移动时的平移矢量,(Xd)是模型移动到左边时的位置。
在上面的例子中,X'= X-d(所以X'是通过X和我的移动d来定义的)。在旋转相机的情况下,X'是什么?
编辑2 :由于 Spektre 不明白我的问题。需要强调的是,在第二种情况下,我不旋转整个世界,我只旋转点X.(如果我旋转整个世界,X的世界坐标在其世界旋转后保持不变,但如果我只旋转X,其世界坐标将变为X')。
想象一下拍摄模型照片的例子。在第一种情况下,我旋转相机并拍下她的第一张照片(和她的男朋友站在她旁边)。
在第二种情况下,我只沿相反方向旋转模型(她的男朋友很稳定),然后我拍第二张照片。当我比较两张照片时,模型的位置是相同的(她的男朋友的位置会不同)。
在这两种情况下,她男朋友的真实世界位置都是一样的。但是,自从我旋转她以来,模型的真实世界位置在第二种情况下发生了变化。我的问题是旋转她后,女孩的真实世界的位置是什么?
解决方案
但我认为标题和文字误导为真正的问题是线性代数矩阵方程。
N x N
和 X
是尺寸 N
的向量。如果我们忽略矢量方向( 1 x N
vs N x 1
),那么对于您的约定:
R2 = R12.R1
R1 =逆(R12).R2
so:
R12.R1.X == R12 。逆(R12).R2.X == R2.X
正如您可以在您的问题是错误的,因为你改变了矩阵乘法顺序,这是错误的,因为:
R1.R12!= R12.R1
如果您想更详细地了解为什么然后研究线性代数。
[Edit1]简单 1x1
示例
R1 = 1
R12 = 2
R2 = R12.R1 = 2
$ b如此重写你的错误方程:
R12 * R1 * X!= R1 *逆(R12)* X
2 * 1 * X!= 1 * 0.5 * X
2 * X!= 0.5 * X
并使用正确的一个
R12 * R1 * X == R12 *逆(R12)* R2 * X == R2 * X
2 * 1 * X == 2 * 0.5 * 2 * X == 2 * X
2 * X == 2 * X == 2 * X
[Edit2]简单的2D示例
我看到您仍然感到困惑,因此这里有一个 2D 示例的问题:
在左侧,您旋转了相机通过
R1
来渲染变换世界点(x,y)
到它的本地坐标( X1,Y1)
。在右边的情况是相反的,所以相机坐标系是轴对齐的(单位矩阵),并且场景以逆(R1)
反向旋转。这就是它的工作原理(在这种情况下R1
是相对矩阵)。
现在,如果我尝试将它移植到你的矩阵名称和约定中,这样相对矩阵是
(x,y)=(x1,y1)R12
和R1
是相机:
逆(R1.R12)。(x1,y1)
(R1.R12) ,y1)=(x,y)
I think rotating the camera and taking the photo of a scene would yield the same result with keeping the camera stable and rotating the scene in reverse way.
Assume that the original camera rotation matrix is R1. Rotating the camera means that we apply another rotation matrix R12 (so R2=R12*R1 is the new rotation matrix). Assume that X is the realworld coordinate of scene point. Rotating the scene point in the reverse way means that we apply the reverse rotation matrix R12^-1 to X (this might be wrong).
So why (R12*R1)X != R1(R12^-1*X) ?
Can anyone explain me what I'm wrong?
p.s. I'm not asking about programing as well as complexity of the two method. I just want to know
(1) the mathematical equation for the action "rotating the scene"
(2) if my assumed equation for "rotating the scene" is correct, why doesn't the mathematical equations reflect the phenomenon in the real world as I described.
Edit 1: According to Spektre's answer, when I rotate the entire scene with the rotation matrix R, then the new camera rotation matrix is
R^-1*R1
In this case, I rotate the entire scene with the rotation matrix R12^-1, then the new camera rotation matrix is
(R12^-1)^-1*R1=R12*R1
However, what if I consider that rotating the camera is equivalent to rotating the scene point X (only the scene point X, not the entire scene). At that time, the rotation matrix of the camera is still R1. But the scene point X now become X'. And the image coordinate of X' is R1*X'. What is the equation for X' ? Note that
R1*X' = R12*R1*X
Of course, you can answer that
X'=R1^-1*R12*R1*X
But I think X' should be defined only by R12 and X (R1 doesn't need to be known to form X'). That's why I ask "what is the mathematical equation for rotating the scene point". X' is the result of the action "rotating X" by some rotation matrix related to R12.
I have another example when the camera does not rotate but move. Assume that I'm taking the photo of a model who is standing right in front of me. Her position is X. My position is C. In the first case, I move to the right (of me) and take the first photo. In the second case, I don't move but the model move the left (of me) with the same steps and I take the second photo. The position of the model in the two image must be identical. This is expressed by the mathematical equation
[R1 -R1*(C+d)]*X = [R1 -R1*C]*(X-d)
In the equation above (which I checked to be true), -R1*C is the translation vector, -R1*(C+d) is the translation vector when I move to the right of me, (X-d) is the position of the model when she move to the left of me.
In the above example, X' = X-d (so X' is defined through X and my movement d). In the case of rotating the camera, what is X'?
Edit 2: Since Spektre still don't understand my question. There's a need to emphasize that in the second case, I DO NOT rotate the ENTIRE world, I ONLY rotate the point X. (If I rotate the entire world, the world coordinate of X remains the same after its world rotate. But if I rotate only X, its world coordinate will be changed to X').
Just imagine the example about taking the photo of the model. In the first case, I rotate the camera and take the first photo of her (and her boy friend standing next to her).
In the second case, I rotate ONLY the model in the reverse direction (her boy friend is stable), then I take the second photo. When I compare the two photos, the position of the model is the same (the position of her boy friend would be different).
In both case, the real world position of her boy friend are the same. But the real world position of the model is changed in the second case since I rotated her. My question is what is the real world position of the girl after I rotate her?
解决方案The answer to Title is: mathematically they are both almost the same (except inversion of all operations) but physically rotating camera means changing single matrix but to rotate scene you have to rotate all the objects in your world (can be thousands and more) which is a lot slower ...
But I assume the title and text is misleading as the real question is about linear algebra matrix equations.
Let
R1,R2,R12
be square matrices of sizeN x N
andX
is vector of sizeN
. If we ignore the vector orientation (1 x N
vsN x 1
) then for your convention:R2 = R12.R1 R1 = Inverse(R12).R2
so:
R12.R1.X == R12.Inverse(R12).R2.X == R2.X
As you can see equation in your Question is wrong because you change the matrix multiplication order which is wrong because:
R1.R12 != R12.R1
If you want to know more closely why then study linear algebra.
[Edit1] simple
1x1
examplelet:
R1 = 1 R12= 2 R2 = R12.R1 = 2
so rewriting your wrong equation:
R12*R1*X != R1*Inverse(R12)*X 2* 1*X != 1* 0.5*X 2*X != 0.5*X
and using the correct one
R12*R1*X == R12*Inverse(R12)*R2*X == R2*X 2* 1*X == 2* 0.5* 2*X == 2*X 2*X == 2*X == 2*X
[Edit2] simple 2D example
I see you are still confused so here an 2D example of the problem:
On the left you got rotated camera by
R1
so for rendering transforming world point(x,y)
into its local coordinates(x1,y1)
. On the right is the situation reversed so camera coordinate system is axis aligned (unit matrix) and the scene is rotated in reverse byInverse(R1)
. That is how it works (whereR1
is the relative matrix in this case).Now if I try to port it to your matrix names and convention so the relative matrix is
R12
andR1
is the camera :(R1.R12).(x,y) = (x1,y1) Inverse(R1.R12).(x1,y1) = (x,y)
这篇关于旋转相机与旋转场景点(只有点,而不是整个场景)有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!