I'm trying to solve for the distance from Obj1 to Obj2 relative to Obj1, because I do not know their global positions, rotations, or the difference between their local spaces.
Thankfully, they are locked to each-other, so their relationship relative to Obj1 is constant across time.
I believe that the following is true, assuming A and B represent discrete samples at different times where the objects moved between A and B:
Obj1.positionB + Obj1.rotationB * relationship = Obj1.positionA + Obj1.rotationA * relationship + (Obj2.positionB - Obj2.positionA)
Given that, we can solve for relationship, right? First, move all instances of relationship to the left side...
Obj1.rotationB * relationship - Obj1.rotationA * relationship = Obj1.positionA + (Obj2.positionB - Obj2.positionA) - Obj1.positionB
From here, the
AB+AC = A(B+C) rule tells me to do this:
(Obj1.rotationB - Obj1.rotationA) * relationship = Obj1.positionA + (Obj2.positionB - Obj2.positionA) - Obj1.positionB
But I know that QuaternionAVector+QuaternionBVector does NOT equal (QuaternionA*QuaternionB)*Vector.
QuaternionA*VectorA+QuaternionB*Vector = VectorB, is it possible to solve for VectorA? How? I'm using Unity, if that's any help.
(Note that the above assumes that the two coordinate spaces are oriented consistently even though they don't share the same origin. Solving for difference in parent space orientation, if ever necessary, is a different problem.)