I'd really appreciate some help on this one.

Given 2 coordinate systems A and B where

  1. xA is an initial Vector3 position, rA is an initial Quaternion rotation
  2. xB is an initial Vector3 position, rB is an initial Quaternion rotation

How can I then transform a random (position, rotation) from A into B?

I can understand how I would go about if I only had position. If I had randomA, it would be randomB = xB + (randomA - xA) to shift from A to B. I'm kind of stuck on where should I incorporate the quaternions / their inverse.


1 Answer 1


I believe something like this should work:

random_position_world = (Quat_A * random_position_A) + xA_world
random_position_B = inverse(Quat_B) * (random_position_world - xB_world)

random_rotation_world = Quat_A * random_rotation_A
random_rotation_B = inverse(Quat_B) * random_rotation_world

The suffix _world here is to denote that the value is expressed in world space. If you want a bit more insight into this sort of thing you should read about transformation matrices.

  • \$\begingroup\$ Meaning that the Quat_x, random_position_x are in local space? \$\endgroup\$
    – G.Pap
    Jul 26 at 10:50
  • \$\begingroup\$ The position, yes. Quat_x is suposed to be the rotation of the coordinate system X with respect to the world's. \$\endgroup\$
    – PepeOjeda
    Jul 26 at 10:58
  • \$\begingroup\$ Gotcha! Thanks! Will look more into it, thanks for the link! \$\endgroup\$
    – G.Pap
    Jul 26 at 11:05
  • \$\begingroup\$ To clarify, this works when world space is common for the two coordinate systems, right? Or does this work when xA, rA - xB, rB come from different world spaces? \$\endgroup\$
    – G.Pap
    Jul 26 at 15:06
  • \$\begingroup\$ Yeah, "World" space is supposed to be the same for all of them. If xA and xB are expressed in different coordinate systems you would need to convert between those as well. That kind of thing is where using matrices becomes super convenient, because concatenating space conversions just becomes multiplying matrices together. If you have the time to go through it, 3Blue1Brown's linear algebra series is the best explanation of all this stuff that I have seen. \$\endgroup\$
    – PepeOjeda
    Jul 26 at 15:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .