Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine multiple rotation matrixes in 3D

I have calculated an axis angle rotations for each axis. If I only apply one of the three rotations, the objects rotates as expected.

If I multiply the rotation matrixes, as you would normally do it if you combine rotations I don't get the desired result, cause the first rotation affects the others and therefore the end result is not what I'm looking for.

I want to apply each rotation to the object as if it wasn't rotated before.

I guess this is a simple task, but it seems that I'm not searching for the right keywords. (Also the title is not perfect ... (open for suggestions))

Thanks for every hint / help.

like image 955
user2479595 Avatar asked Apr 03 '17 16:04

user2479595


People also ask

Can you combine rotation matrices?

Usually an axis vector and a rotation angle is enough to get a rotation matrix. once you have your 3 matrix you can express them as quaternions, multiply them together then express that result into another rotation matrix.

How do you combine rotations?

Rotations in two dimensions are relatively easy, we can represent the rotation angle by a single scalar quantity, rotations can be combined by adding and subtracting the angles.

How do you combine Euler rotations?

To combine two Euler Angle rotations, you need to convert them into rotation matrices first and then multiply them together. Afterward, you can convert the product matrix to Euler Angle representation.

Do rotations in 3D commute?

Rotations About The Same Axis In 3D Are Also Commutative — In general, the composition of 3D rotations is not commutative.


1 Answers

You're experiencing gimbal lock. It's not a maths problem, it's a logical fallacy. Try it with, for the sake of description, your phone:

  1. put it on your desk face up, with the charging connector at the bottom.
  2. rotate clockwise around z by 90 degrees. So the charging connector is now to the left.
  3. rotate around x (which will be the longer axis of the phone assuming the charging port is on the top or bottom) by 180 degrees.
  4. the phone is now upside down, with the charging port on the left.

But:

  1. put it on your desk face up, with the charging connector at the bottom.
  2. rotate around x by 180 degrees. So the charging connector is now at the top.
  3. rotate clockwise around z by 90 degrees.
  4. the phone is now upside down, with the charging port on the right.

Which of those is incorrect if the instruction was to rotate 180 degrees around x and 90 degrees clockwise around z? Neither is incorrect. The instructions were ambiguous.

The order of individual rotations always matters, because the second affects the work done in the first, the third affects the work done in the first and second, etc. Shuffling the order just changes which affects which.

Orientation is normally stored directly as a matrix or as a quaternion because it's unambiguous and because it keeps the order of actions properly ordered.

like image 129
Tommy Avatar answered Sep 22 '22 19:09

Tommy