Browse Source

Math: test and document Matrix4::*projection() harder.

pull/166/head
Vladimír Vondruš 10 years ago
parent
commit
c2d2737ca6
  1. 8
      src/Magnum/Math/Matrix4.h
  2. 14
      src/Magnum/Math/Test/Matrix4Test.cpp

8
src/Magnum/Math/Matrix4.h

@ -193,8 +193,8 @@ template<class T> class Matrix4: public Matrix4x4<T> {
/**
* @brief 3D orthographic projection matrix
* @param size Size of the view
* @param near Near clipping plane
* @param far Far clipping plane
* @param near Distance to near clipping plane, positive is ahead
* @param far Distance to far clipping plane, positive is ahead
*
* @see @ref perspectiveProjection(), @ref Matrix3::projection()
*/
@ -203,8 +203,8 @@ template<class T> class Matrix4: public Matrix4x4<T> {
/**
* @brief 3D perspective projection matrix
* @param size Size of near clipping plane
* @param near Near clipping plane
* @param far Far clipping plane
* @param near Distance to near clipping plane, positive is ahead
* @param far Distance to far clipping plane, positive is ahead
*
* @see @ref orthographicProjection(), @ref Matrix3::projection()
*/

14
src/Magnum/Math/Test/Matrix4Test.cpp

@ -384,7 +384,12 @@ void Matrix4Test::orthographicProjection() {
{0.0f, 0.5f, 0.0f, 0.0f},
{0.0f, 0.0f, -0.25f, 0.0f},
{0.0f, 0.0f, -1.25f, 1.0f});
CORRADE_COMPARE(Matrix4::orthographicProjection({5.0f, 4.0f}, 1, 9), expected);
Matrix4 actual = Matrix4::orthographicProjection({5.0f, 4.0f}, 1.0f, 9.0f);
CORRADE_COMPARE(actual, expected);
/* NDC is left-handed, so point on near plane should be -1, far +1 */
CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -1.0f}), Vector3(0.0f, 0.0f, -1.0f));
CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -9.0f}), Vector3(0.0f, 0.0f, +1.0f));
}
void Matrix4Test::perspectiveProjection() {
@ -392,7 +397,12 @@ void Matrix4Test::perspectiveProjection() {
{0.0f, 7.111111f, 0.0f, 0.0f},
{0.0f, 0.0f, -1.9411764f, -1.0f},
{0.0f, 0.0f, -94.1176452f, 0.0f});
CORRADE_COMPARE(Matrix4::perspectiveProjection({16.0f, 9.0f}, 32.0f, 100), expected);
Matrix4 actual = Matrix4::perspectiveProjection({16.0f, 9.0f}, 32.0f, 100.0f);
CORRADE_COMPARE(actual, expected);
/* NDC is left-handed, so point on near plane should be -1, far +1 */
CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -32.0f}), Vector3(0.0f, 0.0f, -1.0f));
CORRADE_COMPARE(actual.transformPoint({0.0f, 0.0f, -100.0f}), Vector3(0.0f, 0.0f, +1.0f));
}
void Matrix4Test::perspectiveProjectionFov() {

Loading…
Cancel
Save