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?
- !
, . , . - , , . , , ; .
( " ".)
, .
, quaternions , . gimbal lock, .
.
, , 90 , 90 , 90 , , , ( 90 ).
. , , // , . , , , , , , . / , () phi (). , , . /, . theta/phi , , phi, theta , . FPS ( , ).
2. , , rotLati(float angle) rotLongi(float angle).
rotLati(float angle)
rotLongi(float angle)
, . , pitch(), yaw(), yaw(), pitch(), , , , . , pitch() es yaw() s roll() , . ( , )
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.
I believe this circumstance is called Gimbal Lock - here is an example of this with illustrations on the wikipedia page.
Source: https://habr.com/ru/post/1707098/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1707093/can-someone-explain-how-i-can-use-quanternions-to-use-the-mouse-to-look-around-like-a-fps&usg=ALkJrhhClaudrn6PBxmN07q6rdJw-lgH7QWord Wrap in Windows Forms (vb.net) - vb.netFCKEditor in asp.net-mvc - asp.net-mvcGoogle Web Toolkit: installing RichTextArea for a PHP application - javaIs everything all right if from one stored procedure I call another which sets lower transaction isolation level? - sql-serverHow to make a property public, but private, set in vb.net? - vb.netShould I use global variables or pass variables in java? - javaThe fastest way to find the minimum distance between points - algorithmWhat does the Warning: return do integer from a pointer without casting in C? - cBest Visual Studio 2008 Tutorial for Debugging? - debuggingAll Articles