To main page | 3dengine.org

Pitch


Pitch (in Heading, pitch and roll angles) is the rotation around HORIZONTAL axis. Which is X-positive (or 1,0,0) in default OpenGL.

It determines whether camera is looking up or down (or any in-between).



Limits

Usually its -90 degress to 90 degrees (-91 degree is the same as looking BACK(heading=180deg) and UPSIDE DOWN(roll=180), therefore pitch should be limited to -90 to 90 - anything after that can be expressed via other heading and roll).

Singularity

When pitch is -90 or 90 degress, the heading and roll is pretty much the same thing - it doesn't matter whether human, looking exactly up, is rotating only his head around the center of his eyes (roll) or he is rotating with all his body around vertical axis (heading).

Calculating pitch from MODELVIEW matrix

if (abs(modelview[2])<0.001) {
   pitch = asin(modelview[6])*RAD2DEG; // singularity
} else {
   pitch = atan2(-modelview[1], modelview[2])*RAD2DEG;
};
if(pitch<-90) { pitch=pitch+180; } // limit pitch to -90 to 90 range
if(pitch>90) { pitch=pitch-180; }
where modelview is modelview matrix.