Rotation of an object in 3D

69 Views Asked by At

I want to rotate a 3D object using a python code. After doing some search, I was able to come up with the following initial steps:

  1. Input the Euler axis,
  2. input the Euler angle of rotation,
  3. Normalize the Euler axis,
  4. Define the Z-axis (the slicing direction (0 0 1), and
  5. Compute the orientation vector. I am stuck at the 5th step.

After doing extra search, I found the following equation: enter image description here

I can't seem to understand the concept of this equation (I know it is the multiplication of sin Euler angle by the cross product of Z axis and Euler axis, etc... but what I am trying to say is that I don't understand its derivation nor from where it comes from). Further, what's the difference between the orientation vector computed by this equation and the Euler axis? Is the orientation vector used to define the direction of rotation?

1

There are 1 best solutions below

0
On

The easiest way to program rotations in 3D is through quaternions. Quaternions are like complex numbers embedded in 4 dimensions.

If the origin is not on the axis or rotation translate your coordinates so that it is.

Let $\bf \hat v$ be a unit vector (in $\bf i,j,k$ notation) that represents your axis of rotation.

Let $\bf p$ be a point in space that you want to rotate around this axis.

$(\cos \frac {\theta}{2} + \mathbf {\hat v} \sin \frac {\theta}{2})\mathbf p(\cos \frac {\theta}{2} - \mathbf {\hat v} \sin \frac {\theta}{2})$

Will perform your rotation.

However, you must follow the algebra of quaternions.

$\mathbf i^2 = \mathbf j^2 = \mathbf k^2= -1\\ \mathbf i\mathbf j\mathbf k = -1$

And, multiplication of the vector components is anti-symmetric. That is:

$\mathbf i\mathbf j=\mathbf k\\ \mathbf j\mathbf k = \mathbf i\\ \mathbf k\mathbf i = \mathbf j $

While

$\mathbf j\mathbf i = -\mathbf k\\ \mathbf k\mathbf j = -\mathbf i\\ \mathbf i\mathbf k = -\mathbf j $

The real part behaves like the real part in a complex number.

I don't have enough space here to explain why it works. But play with it and see if you can't make it come out right.