A little quaternion problem

Started by
1 comment, last by dense 22 years, 2 months ago
I've recently implemented quaternions into my engine, and everything seems to work properly except for one thing. I convert my yaw/pitch/roll to quaternion, multiply it by the previous frames quaternion, then I convert that to a matrix, then apply that matrix to the current one, that works fine and dandy. The problem comes when I want to move the camera. From what I understand, I just have to add the forward vector to the current camera position and I'll have my new position. This works perfect when the roll and pitch are at 0.0. But for some reason, when applying pitch, the y value of the camera's position is not calculated properly when facing certain directions. And also, when I apply roll to the situation, the y value gets even more messed up. When not moving though, the view is calculated just fine using yaw/pitch/roll, so I'm a little stumped. To get the forward vector, I just extract it from the matrix I create, so I don't see why it should be getting screwed up. Is this a common thing when using quats or am I doing something wrong? Any help is appreciated. Edited by - dense on January 25, 2002 6:24:46 PM
Advertisement
It sounds like you just have a bug in your code
somewhere. This is not common at all.

-Jonathan.
You may be "extracting" the facing vector the wrong way. It could be the 3rd row or 3rd column of the 4x4 matrix. It depends on the API you''re using. But grabbing the wrong column/row will give you correct x & z values with wacky y values.

It''s hard to guess without looking at the code.

This topic is closed to new replies.

Advertisement