# quaternion camera wrong!

This topic is 939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

first question :
here's a quaternion q to specify rotation.
Is it correct to apply a rotation( init by axis angle ) to q use the formula?
q' =  Quaternion(axis, angle) * q;

I use Quaternion as direction of camera.

invertPitch means reverse the flag of pitch.
my solution is get the forward vector of quaternion direction,
then get the horizon forward vector by setting the y to 0.
then compute the angle between two vector.
then rotate two times of the angle.
I don't know why the result quaternion sometimes(some special case)  become  INF, INF,INF,INF.
is there any mistake on my solution ?
or is there other more intuitive solution to get and set the pitch ?

void Camera::invertPitch()
{
vector3f forward = getForward();

int flag = (forward.getY() > 0 ? 1 : -1);
vector3f horizonF = forward*10;               // in case the x, z component close to 0.
horizonF.setY(0);
horizonF = horizonF.normalized();

}
Edited by poigwym

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633725
• Total Posts
3013558
×