How to Build Rotation Matrix From Orientation Vectors

Here is a vector in 3-d space:

We can express this vector with three linearly-independent vectors and coefficients:

We can also write this in matrix form:

The three vectors are called as a basis in 3-d space, as they can be used to express any vector in 3-d space. Especially they are called as the standard basis, because the basis is what we normally think in.

Of course, we can have another basis to express the same V. Let’s try one:

Similarly, in matrix form:

where .

Now, let’s say we have three vectors that represent the orientation of an object in the world. Notice that we need at least two vectors; one to represent where the object looks at, and the other to indicate the up direction. If we have two linearly independent vectors, we can easily create the third one by cross-producting the two.

Now, let’s call the three vectors as side(or right, X), forward(Z), up(Y) vectors each, and the orientation basis altogether.

Let there be an arbitrary point . In standard basis, is written as:

In orientation basis, is written as:

Notice that is P , but expressed in the orientation basis.

Since they are the same P:

To find Q expressed in the standard basis, we multifly the inverse of the orientation basis matrix to each side’s left:

Now, is expressed in the standard basis. To make it clear, we can write it as:

We can induce from it that the inverse of orientation basis matrix transforms any point in orientation basis to be expressed in the standard basis.

Notice, because the orientation basis vectors are all orthogonal to each other, we can inverse the the matrix simply by transposing the matrix:

In conclusion, given that we know forward, up, side vectors of an object, making the rotational transform matrix to the world space is very easy and efficient, as putting them in rows in order does the trick.

Posted in Game Programming, Mathematics, Uncategorized and tagged , , , , .

Leave a Reply

Your email address will not be published. Required fields are marked *