I am having problems setting the camera such that it points at the origin O(0,0,0) with a degree of 45° to all other axes with all coordinates positive (which should have the same value, of course). You can see in the image the closest I've got
However, as you can see, the x
value is negative here, so the camera is on the wrong side of the YZ
plane.
The complete compilable project can be found at this revision in a gist.
The relevant matrix multiplications done 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
.
I'm trying to figure out how this works (both mathematically and programmatically). I would prefer solutions which rely as little as possible on openscenegraph, and more on the math side, as I'd like to do the maths myself at first, to get a real grasp of how it works. So no quaternions or other advanced stuff yet, which are not taught in a basic linear algebra university course.