Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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 = horizonF.normalized();
float rad = acos(horizonF.dot(forward));
rotateX(2 * rad *flag);
Edited by poigwym

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!