-#include <algorithm>
#include <cmath>
-#include <msp/geometry/affinetransformation.h>
-#include "error.h"
+#include <stdexcept>
+#include <msp/geometry/affinetransform.h>
#include "matrix.h"
using namespace std;
Matrix Matrix::translation(const Vector3 &t)
{
- return Geometry::AffineTransformation<float, 3>::translation(t).get_matrix();
+ return Geometry::AffineTransform<float, 3>::translation(t).get_matrix();
}
Matrix Matrix::rotation(const Angle &a, const Vector3 &x)
{
- return Geometry::AffineTransformation<float, 3>::rotation(a, x).get_matrix();
+ return Geometry::AffineTransform<float, 3>::rotation(a, x).get_matrix();
}
Matrix Matrix::scaling(const Vector3 &s)
{
- return Geometry::AffineTransformation<float, 3>::scaling(s).get_matrix();
+ return Geometry::AffineTransform<float, 3>::scaling(s).get_matrix();
}
Matrix Matrix::ortho(float l, float r, float b, float t, float n, float f)
Matrix result;
result(0, 0) = 2/(r-l);
result(1, 1) = 2/(t-b);
- result(2, 2) = -2/(f-n);
+ result(2, 2) = -1/(f-n);
result(0, 3) = -(r+l)/(r-l);
result(1, 3) = -(t+b)/(t-b);
- result(2, 3) = -(f+n)/(f-n);
+ result(2, 3) = 0.5f-0.5f*(f+n)/(f-n);
return result;
}
result(1, 1) = 2*n/(t-b);
result(0, 2) = (r+l)/(r-l);
result(1, 2) = (t+b)/(t-b);
- result(2, 2) = -(f+n)/(f-n);
+ result(2, 2) = -f/(f-n);
result(3, 2) = -1;
- result(2, 3) = -2*f*n/(f-n);
+ result(2, 3) = -f*n/(f-n);
result(3, 3) = 0;
return result;
}