# Matrix rotations

• May 12th 2008, 12:41 PM
trellend
Matrix rotations
I'm storing a matrix to represent the rotational position of a ball. I initialize it to an identity matrix of 100 010 001, which represent the x axis in my coord space.

When the ball receives an impulse, it starts traveling in said direction, but sufarce friction makes it start to roll. I've calculated the axis of rotation, and multiplied that original vector by a matrix formed from a quaternion.

This works perfectly, until the ball bounces off of something other than a 180 degree turn around. It works in all direction of impulse, until it gets off of it's x-y-z initial axis.

I'm new here, so I don't exactly know what to provide to help you help me. So please take that into consideration. I can tell the rotation is working because I am raytracing the ball, using the matrix to rotate a vector from the center of the ball to the outside, then using that to look up UV coords in a texture map.

I believe the problem is that I need to rotate my rotation matrix before I multiply it to the existing matrix...

Ideas?
• May 12th 2008, 02:31 PM
trellend
*********FIXED********

Apparently if you want to rotate ball by it's own (relative axis) you do current_matrix * what_to_rotate_by

But if you want to rotate by a World axis, you
current_matrix = what_to_rotate_by * current_matrix

So simple.