1
votes

I'm reading the Billboarding section in the book Real-Time Rendering and the author explains that in order to rotate a quadrilateral (i.e the billboard) to a certain orientation, the rotation matrix will be

M = (r, u, n)

Where r, u, n are the calculated (normalized) direction vectors.

From the book: enter image description here

I've learned that in order to rotate stuff one must use a matrix that includes lots of dirty sin() and cos() calculations. How come this M matrix uses plain direction vectors?

2
Note that your question has little to do with programming:)Andras Deak
Shh! I'm reading your answersPilpel
If I can offer another alternative, consider using the axis-angle representation to rotate things. It's frequently used in robotics: stackoverflow.com/questions/32485772/…rayryeng

2 Answers

3
votes

Sine and cosine are used only when you want to convert from an angle representation to a vector representation. But let's first analyze what makes a matrix a rotation matrix.

Rotation matrices are ortho-normal and have determinant +1. That means that their column vectors are of unit length and that they are perpendicular to each other. One nice property of ortho-normal matrices is that you can invert them by transposing them. But that's just a nice feature.

If we have the 2D rotation matrix

M = /  cos a   sin a \
    \ -sin a   cos a /

, we see that this is the case. The first column vector is (cos a, -sin a). From the Pythagorean theorem, we get that this vector has unit length. Furthermore, it is perpendicular to the second column vector (their dot product is zero).

So far, so good. This matrix is a rotation matrix. But can we interpret the column vectors? Indeed, we can. The first column vector is the image of the vector (1, 0) (i.e. the right vector). The second column vector is the image of the vector (0, 1) (i.e. the up vector).

So you see that using sine and cosine are just another way to calculate the direction vectors. Doing so automatically ensures that they have unit length and that they are orthogonal to each other. But this is just one way. You can also calculate the direction vectors using the cross product or any other scheme. The critical point is that the rotation matrix properties are fulfilled.

2
votes

You need those dirty trigonometric functions if your transformation is given with angles. However, if instead you know the image of the Cartesian unit vectors, you can construct the matrix easily.

If the image of [1; 0; 0] is r, [0; 1; 0] is u and [0; 0; 1] is n, then the effect of the matrix will be

M * [1; 0; 0] == 1*r + 0*u +0*n == r
M * [0; 1; 0] == 0*r + 1*u +0*n == u
M * [0; 0; 1] == 0*r + 0*u +1*n == n

which is exactly the transformation you need, if your matrix is M=[r u n].

Note that this will in general give you an affine transformation, it will only be a rigid rotation if your vectors are orthonormal.