Pointing the camera at O โ€‹โ€‹(0,0,0), 45 degrees

I am having problems installing the camera so that it points to the origin O (0,0,0) with a degree of 45 ยฐ with respect to all other axes with all positive positions (which should have the same value, of course), you can see the closest I have on the image

enter image description here

However, as you can see, the value xhere is negative, so the camera is on the wrong side of the plane YZ.

A complete compiled project can be found in this revision in essence .

The corresponding matrix transformations are

osg::Matrixd rotate_x(
        1.0, 0.0, 0.0, 0.0,
        0.0, q_cos, -q_sin, 0.0,
        0.0, q_sin, q_cos, 0.0,
        0.0, 0.0, 0.0, 1.0 
);
osg::Matrixd rotate_y(
        q_cos, 0.0, q_sin, 0.0,
        0.0, 1.0, 0.0, 0.0,
        -q_sin, 0.0, q_cos, 0.0,
        0.0, 0.0, 0.0, 1.0 
);
camera_pos = camera_pos * rotate_x;
camera_pos = camera_pos * rotate_y;

in the file Simple.cpp.

, ( , ). , openscenegraph, , , , . , .

+5
2

rotate_y .

glRotate, xyz = (0,1,0), ( ( opengl)

 q_cos  0  q_sin   0 
 0      1  0       0 
-q_sin  0  q_cos   0
 0      0  0       1

:

osg::Matrixd rotate_y(
        q_cos,  0.0, q_sin,  0.0,
        0.0,    1.0, 0.0,    0.0,
        -q_sin, 0.0, q_cos,  0.0,
        0.0,    0.0, 0.0,    1.0
);

-q_sin [2] , q_sin [8], , .


EDIT

OpenGL OSG , 4x4, , .

[0]    [4]     [8]     [12]
[1]    [5]     [9]     [13]
[2]    [6]     [10]    [14]
[3]    [7]     [11]    [15]

[0] - , 1 - ..

OSG, 16 , [0] [15]

osg::Matrixd rotate_y([0], [1], [2]......,[15]);

4 , :

osg::Matrixd rotate_y(
   [0], [1], [2], [3],
   [4], [5], [6], [7],
   [8], [9], [10],[11],
   [12],[13],[14],[15] 
)

, ? , 4x4 - , , . , , , "", .

+1

. (0,0,500) x y, (0,0,500) acos(q_cos) asin(q_sin) .

0

All Articles