I need your help to solve a trigonometry problem, I'm unable to find any documentation about on the web...

For convenience, I will use "transform" to indicate a position+orientation.

Let's say that we have a general shape (the green box) and we apply to it a displacement and a rotation to obtain the blue box (the grey box represents a possible interpolation between the initial and the final transform) enter image description here

Now, suppose that the transform we apply produce this result. To match the blue box transformation we could simply apply a rotation to the green box with the center represented by the orange dot. enter image description here

The question is the following: Is it possible to compute the center of rotation for any generic case knowing only the transformations of the green and the blue box? Ex: enter image description here

Why this need? Consider the image n2, if I simply interpolate [0,5] the transformation of the green and the blue box I obtain the grey box of the image n1, what I'm looking for is a way to obtain the grey box of the image n2.

Thank you so much!

  • \$\begingroup\$ Do you have a transformation matrix from green to blue, or do you have only the initial and final positions of the vertex? \$\endgroup\$
    – Theraot
    Commented Dec 21, 2022 at 21:57
  • \$\begingroup\$ I have the orientation matrices (so the box x,y,z axes oriented in the world) of the green and the blue box and their positions ... \$\endgroup\$ Commented Dec 22, 2022 at 19:28
  • \$\begingroup\$ From the orientation matrices, it is a simple coplaner projection to get a line, line intersection point, calculate the 2 angles and radius, average the two angles and give the projection of the grey object's position. \$\endgroup\$
    – user122973
    Commented Dec 23, 2022 at 5:20
  • \$\begingroup\$ The key term is co-planar. Assuming you want the shortest answer or the longer one as there are 2 for all orientations, except the following: the only ambiguity of the median is if the blue and green boxes are co-linear either 0 degrees to which there is no answer, or 180 degrees to which the the answers lay on disc perpendicular to the center. \$\endgroup\$
    – user122973
    Commented Dec 23, 2022 at 5:43
  • \$\begingroup\$ @Strom, It's hard for me to understand your response and apply your solution. I have to "co-plane project" the two matrices? What line I get? What point I have to intersect with that line? ... Maybe you can provide me a more explicit example? Thank you \$\endgroup\$ Commented Dec 23, 2022 at 17:40

1 Answer 1


I'm afraid it's not quite possible, simply because there is always more than one solution. For example, even if we know the rotation center, you can get the same final pose by rotating in different ways: Rotating around the same point using different directions ends up getting the same result

But even using different points as rotation center can work as well: Same final pose rotating around different points

So, in order to automate this process, you would have to introduce additional constraints (like, for example, fix the direction in which you want to rotate). The specifics of how to solve it then would depend on which constraints you choose and how you define the positions and orientations.

  • 2
    \$\begingroup\$ These transformations all match the green box's vertices to the blue box, but in different orientations. If we distinguish the sides of the boxes in some way — say making one end wider and putting a bump on one face — then only one of these transformations will being them into alignment, and the others will mismatch which side is flared/bumped. Viewed another way, if we have the boxes expressed as a translation vector and an orientation quaternion, there's exactly one shortest rotation that maps the first orientation to the second (or two if they're exactly 180 degrees apart). \$\endgroup\$
    – DMGregory
    Commented Dec 22, 2022 at 12:19
  • \$\begingroup\$ That's a good point! \$\endgroup\$
    – PepeOjeda
    Commented Dec 22, 2022 at 14:36
  • \$\begingroup\$ Thank you both! So it's maybe possible to find that shortest rotation with some calculation? The double result of the 180° case will not be a problem... \$\endgroup\$ Commented Dec 22, 2022 at 19:22
  • \$\begingroup\$ This is over thought. The first rotation of the top image is an arbitrary spherical rotation. \$\endgroup\$
    – user122973
    Commented Dec 23, 2022 at 5:48

You must log in to answer this question.

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