• Create Account

### #ActualZBethel

Posted 21 July 2012 - 06:11 PM

You're intuition about your current code rotating the camera around the origin is correct. You want to use the inverse of the rotation matrix when you apply it to the view, because the view matrix is a glorified inverse world matrix for the camera. Try swapping the order of the matrices when you multiply them in rotate(...). Remember, the inverse of a rotation matrix is its transpose.

Right now you have:

view = view * rotation.

I believe you want:

view = rotation * view.

The reason this works is that flipping the multiplication is equivalent to transposing the rotation matrix before multiplying like you were before. As it turns out, the transpose of a rotation matrix is its inverse.

EDIT: After thinking about it, I don't think this is correct either. I think the issue is that you you're trying to rotate a matrix that has already been translated. You're probably better off doing what Martin Perry suggested.

### #4ZBethel

Posted 21 July 2012 - 05:07 PM

You're intuition about your current code rotating the camera around the origin is correct. You want to use the inverse of the rotation matrix when you apply it to the view, because the view matrix is a glorified inverse world matrix for the camera. Try swapping the order of the matrices when you multiply them in rotate(...). Remember, the inverse of a rotation matrix is its transpose.

Right now you have:

view = view * rotation.

I believe you want:

view = rotation * view.

The reason this works is that flipping the multiplication is equivalent to transposing the rotation matrix before multiplying like you were before. As it turns out, the transpose of a rotation matrix is its inverse.

### #3ZBethel

Posted 21 July 2012 - 05:05 PM

You're intuition about your current code rotating the camera around the origin is correct. You want to use the inverse of the rotation matrix when you apply it to the view, because the view matrix is a glorified inverse world matrix for the camera. Try swapping the order of the matrices when you multiply them in rotate(...). Remember, the inverse of a rotation matrix is its transpose.

Right now you have:

view = view * rotation.

I believe you want:

view = rotation * view.

The reason this works is that flipping the multiplication is equivalent to transposing the rotation matrix before multiplying like you were before. As it turns out, the transpose of a rotation matrix is its inverse.

### #2ZBethel

Posted 21 July 2012 - 05:04 PM

You're basically rotating your camera around the origin. I believe you want to use the inverse of the rotation matrix when you apply it to the view, because the view matrix is a glorified inverse world matrix for the camera. Try swapping the order of the matrices when you multiply them in rotate(...). Remember, the inverse of a rotation matrix is its transpose.

### #1ZBethel

Posted 21 July 2012 - 05:03 PM

You're basically rotating your camera around the origin. I believe you want to use the inverse of the rotation matrix when you apply it to the view. Try swapping the order of the matrices when you multiply them in rotate(...). Remember, the inverse of a rotation matrix is its transpose.

PARTNERS