No, C0
is not the CFrame for Part1 relative to Part0 unless both Transform
and C1
are identity matrices.
The CFrame of Part1
relative to Part0
is Part0.CFrame:Inverse() * Part1.CFrame
. By solving this expression from the equation in my answer above we can get an expression for this relative CFrame
in terms of C0
, Transform
and C1
.
The equation:
Part0.CFrame * Motor6D.C0 * Motor6D.Transform = Part1.CFrame * Motor6D.C1
We can think of each side of the equation as a single matrix (which is the result of the operations written in the equation). When doing the exact same operation on both sides of the equation, the equation stays valid.
The addition needs to be made to the same side of the original matrix (expression) on both sides of the equation. This is because A * B is usually not equal to B * A when A and B are matrices. In this case I add it to the left of the original expressions on both sides.
Part0.CFrame:Inverse() * (Part0.CFrame * Motor6D.C0 * Motor6D.Transform) = Part0.CFrame:Inverse() * (Part1.CFrame * Motor6D.C1)
Although the rules for preserving equality in matrix operations are more strict than the ones for preserving equality in operations on numbers, matrices A, B and C satisfy the equation A * (B * C) = (A * B) * C. Because A * B * C has the same order of operations as (A * B) * C (which means they are equal), we can conclude that A * (B * C) = A * B * C.
Obviously, A * (B * C * D) = A * ((B * C) * D) because of same order of operations. From the equation that I wrote above (which was A * (B * C) = A * B * C) we can conclude that
A*((B*C)*D) = A*(B*C)*D = (A*(B*C))*D = (A*B*C)*D = A*B*C*D
A more detailed explanation of the above sequence of equations
- A * ((B * C) * D) = A * (B * C) * D follows from the equation A * (B * C) = A * B * C.
- A * (B * C) * D = (A * (B * C)) * D because these have the same order of operations.
- (A * (B * C)) * D = (A * B * C) * D follows from the equation A * (B * C) = A * B * C.
- (A * B * C) * D = A * B * C * D because these have the same order of operation.
Based on this, A * (B * C * D) = A * B * C * D, which means the Motor6D
equation can be simplified to this:
Part0.CFrame:Inverse() * Part0.CFrame * Motor6D.C0 * Motor6D.Transform = Part0.CFrame:Inverse() * Part1.CFrame * Motor6D.C1
Multiplying a matrix and its inverse matrix gives an identity matrix, which can be left out of the equation (because multiplying a matrix by identity matrix gives the original matrix). Thus, the equation can be further simplified:
Motor6D.C0 * Motor6D.Transform = Part0.CFrame:Inverse() * Part1.CFrame * Motor6D.C1
Nextx we can add * Motor6D.C1:Inverse()
to the end of both sides of the equation:
Motor6D.C0 * Motor6D.Transform * Motor6D.C1:Inverse() = Part0.CFrame:Inverse() * Part1.CFrame * Motor6D.C1 * Motor6D.C1:Inverse()
Based on the equation A * (B * C) = A * B * C we can write the Motor6D
equation as follows:
Motor6D.C0 * Motor6D.Transform * Motor6D.C1:Inverse() = (Part0.CFrame:Inverse() * Part1.CFrame) * (Motor6D.C1 * Motor6D.C1:Inverse())
Here A = Part0.CFrame:Inverse() * Part1.CFrame
, B = Motor6D.C1
and C = Motor6D.C1:Inverse()
’
Once again, we have an expression that gives an identity matrix. Thus, we can finally write the equation like this:
Motor6D.C0 * Motor6D.Transform * Motor6D.C1:Inverse() = Part0.CFrame:Inverse() * Part1.CFrame
Now, the right side is Part0.CFrame:Inverse() * Part1.CFrame
which is the CFrame
of Part1
relative to Part0
. Thus, this relative CFrame in terms of C0
, Transform
and C1
is the following:
Motor6D.C0 * Motor6D.Transform * Motor6D.C1:Inverse()
Here's an explanation of why the relative CFrame is Part0.CFrame:Inverse() * Part1.CFrame
Let’s call the relative CFrame
X, part0.CFrame A and Part1.CFrame B.
We can form the equation A*X = B. Let’s edit this equation:
A*X = B
A:Inverse()*(A*X) = A:Inverse()*B -- A:Inverse()* added to both sides
A:Inverse()*A*X = A:Inverse()*B -- equation A*(B*C) = A*B*C
X = A:Inverse()*B -- Identity matrix can be left out.