How can you just call Pitch () and Yaw () to force the camera to ultimately Roll ()?

I am coding a basic OpenGL game, and I have code that the mouse processes in terms of camera movement.

I am using the following method:

int windowWidth = 640;
int windowHeight = 480;

int oldMouseX = -1;
int oldMouseY = -1;

void mousePassiveHandler(int x, int y)
{
    int snapThreshold = 50;

    if (oldMouseX != -1 && oldMouseY != -1)
    {
        cam.yaw((x - oldMouseX)/10.0);
        cam.pitch((y - oldMouseY)/10.0);


        oldMouseX = x;
        oldMouseY = y;

        if ((fabs(x - (windowWidth / 2)) > snapThreshold) || (fabs(y - (windowHeight / 2)) > snapThreshold))
        {
            oldMouseX = windowWidth / 2;
            oldMouseY = windowHeight / 2;
            glutWarpPointer(windowWidth / 2, windowHeight / 2);
        }
    }
    else
    {
        oldMouseX = windowWidth / 2;
        oldMouseY = windowHeight / 2;
        glutWarpPointer(windowWidth / 2, windowHeight / 2);
    }


    glutPostRedisplay();

}

However, looking around the circles in a circle, you will find that the camera begins to "roll" (rotate). Since I only call Pitch and Yaw, I do not see how this is possible.

Here is the code I use for my Camera class: http://pastebin.com/m20d2b01e

As far as I know, my camera "rolls" should not happen. It should just move up and down or growl left and right. NOT a roll.

What could be the reason for this?

+1
source share
6

- !

, . , . - , , . , , ; .

( " ".)

, .

+11
+7

, , 90 , 90 , 90 , , , ( 90 ).

. , , // , . , , , , , , . / , () phi (). , , . /, . theta/phi , , phi, theta , . FPS ( , ).

2. , , rotLati(float angle) rotLongi(float angle).

+5

, . , pitch(), yaw(), yaw(), pitch(), , , , . , pitch() es yaw() s roll() , . ( , )

+4
source

Pitch / yaw / roll refer to the orientation of your car. When you raise / lower, you change your yaw axis. Similarly, when you scour, you change the pitch axis. Thus, you can change your orientation in the same way as a roll maneuver, only by combination and mast and yaw maneuvers.

+3
source

I believe this circumstance is called Gimbal Lock - here is an example of this with illustrations on the wikipedia page.

+3
source

Source: https://habr.com/ru/post/1707098/


All Articles