Page 1 of 1

Matrix for rotation about an arbitrary axis

Posted: October 20th, 2014, 8:39 pm
by BurakCanik
Hi folks. I've been reading the book "Introduction to 3D Grame Programming with Directx 11" by Frank D. Luna. I couln't solve an excersize question from the book, so I thought maybe you guys could help.
The question is this :
Build a rotation matrix that rotates 30 degrees along the axis (1,1,1).

I'm attaching some photos, which show :
1st one : Solution of the problem.
2nd 3nd one : How the subject is explained on the book

I don't understand why they are not using (1,1,1) for (x,y,z) values in rotation matrix formula. Instead they are using ( (1/root of 3), (1/root of 3), (1/root of 3) ). Can someone explain ?

Thanks in advance dudebros.

Re: Matrix for rotation about an arbitrary axis

Posted: October 20th, 2014, 8:44 pm
by BurakCanik
I'm also uploading a photo of the formula of rotation matrix exclusively, so you guys can understand the problem easier.

Re: Matrix for rotation about an arbitrary axis

Posted: October 21st, 2014, 1:17 am
by albinopapa
it's so it's a unit vector, I'm guessing. Unit vector magnitude is 1. You get magnitude by squaring the components then taking the square root of their sums. So square(1 / sqrt(3) ) is 1/3. 1/3 + 1/3 + 1/3 = 1 and sqrt( 1 ) = 1.


Edit: http://www.cprogramming.com/tutorial/3d ... nions.html

This webpage is something I found while looking for some of my own answers. If you build the matrix with all axes (X, Y, Z) being 0 and the fourth ( W ) being 1 (0, 0, 0, 1), the resulting vector from multiplying the vector and matrix is the Identity Matrix

1, 0, 0, 0
0, 1, 0, 0
0, 0, 1, 0
0, 0, 0, 1

The rest of the page might be useful to you as well

Edit 2: Another helpful page that has finally helped me figure out the camera movement for 1st person view.
http://3dgep.com/understanding-the-view ... iew_Matrix

Re: Matrix for rotation about an arbitrary axis

Posted: October 22nd, 2014, 7:33 pm
by BurakCanik
OKAY I found out why.

http://en.wikipedia.org/wiki/Rotation_matrix

Scroll down to the title "Rotation matrix from axis and angle". You'll see the matrix I was talking about. And I quote, it is "the matrix for a rotation by an angle of θ about an axis in the direction of u". THAT'S WHY ( 1 / sqrt(3) ) IS USED INSTEAD OF 1. Components of the vector are normalized so that you get a vector which points in the direction of the vector (1,1,1) and has a magnitude of 1 units.

I'm so furious at Frank D. Luna right now. Why the hell would you not include this super simple and short sentence in your book ? I bet this stupid and simple shit was the reason my follicles felt like they were pulled by a thousand men during the day. That or I have some problems with my hair that I should really be worried about. Anyways I'm relieved now.

Also albinopapa thanks for those links. Even though quaternions are covered on the last third of the book I read it. A little info before I dive into the subject is something I really appreciated. Also I know where to look if I don't get it when I'm reading that chapter. Haven't got time to look at the second link you mentioned but it seems like a comprehensive tutorial about the view matrix. I'll certainly give it a look when I get there. Thanks!

Re: Matrix for rotation about an arbitrary axis

Posted: October 22nd, 2014, 7:38 pm
by BurakCanik
Though when I think about it, I should have deduced that if I have a formula in which I need to use a vector whose magnitude is 1 and I have a vector whose magnitude is not 1, the logical thing to do is normalizing it. So turns out I'm the one I should be furious at and who's as dumb as a rock. So yeah :D Good day everybody.