Converting quaternion or $4\times 4$ matrix to $3\times 3$ matrix representation.

941 Views Asked by At

I'm working on some code that manipulates an Axis-Aligned Bounding Box (AABB), so it always encompasses the object it borders. I use a $3\times 3$ matrix to re-size the box when it rotates.

The only issue is I only have a $4\times 4$ matrix, based off of a quaternion rotation, to work with. Currently, I'm using the $4\times 4$ matrix to change the size of the AABB, but this only works correctly on two dimensions.

So, how would I convert a quaternion representation of rotations to a $3\times 3$ matrix? (Converting it first to a $4\times 4$ matrix seems like it might be an unnecessary step.)

1

There are 1 best solutions below

0
On

how would I convert a quaternion representation of rotations to a 3x3 Matrix?

You could just compute the images of $i,j,k$ using the quaternion version, and use the coefficients as columns in a new matrix. This would give you the 3 by 3 matrix for your transformation, acting on the left of column vectors.

Depending on how you are using the quaternions ($q\_q^{-1}$ or $q^{-1}$_q?) you may need to transpose this and use rows instead.