18 #ifndef ION_MATH_TRANSFORMUTILS_H_
19 #define ION_MATH_TRANSFORMUTILS_H_
59 template <
int Dimension,
typename T>
63 for (
int row = 0; row < Dimension; ++row) {
64 for (
int col = 0; col < Dimension; ++col)
65 result[row] += m(row, col) * v[col];
75 template <
int Dimension,
typename T>
79 for (
int row = 0; row < Dimension; ++row) {
80 for (
int col = 0; col < Dimension; ++col)
81 result[row] += m(row, col) * p[col];
82 result[row] += m(row, Dimension);
91 template <
int Dimension,
typename T>
95 for (
int row = 0; row < Dimension; ++row) {
96 for (
int col = 0; col < Dimension; ++col)
97 result[row] += m(row, col) * p[col];
98 result[row] += m(row, Dimension);
101 T homogeneous_coordinate = m(Dimension, Dimension);
102 for (
int col = 0; col < Dimension; ++col)
103 homogeneous_coordinate += m(Dimension, col) * p[col];
106 if (homogeneous_coordinate !=
T(0))
107 result /= homogeneous_coordinate;
117 template <
typename T>
120 m(1, 0), m(1, 1), m(1, 2),
121 m(2, 0), m(2, 1), m(2, 2));
127 template <
typename T>
140 template <
int Dimension,
typename T>
144 MatrixType result = MatrixType::Identity();
145 for (
int row = 0; row < Dimension; ++row)
146 result[row][Dimension] = t[row];
154 template <
int Dimension,
typename T>
157 for (
int row = 0; row < Dimension; ++row) {
158 for (
int col = 0; col < Dimension + 1; ++col)
159 result[row][col] = row == col ? s[row] : static_cast<T>(0);
162 for (
int col = 0; col < Dimension; ++col)
163 result[Dimension][col] = static_cast<T>(0);
164 result[Dimension][Dimension] =
static_cast<T>(1);
171 template <
int Dimension,
typename T>
174 for (
int row = 0; row < Dimension; ++row) {
175 for (
int col = 0; col < Dimension; ++col)
176 result[row][col] = row == col ? s[row] : static_cast<T>(0);
183 template <
typename T> ION_API
189 template <
typename T> ION_API
195 template <
typename T>
204 template <
typename T>
220 template <
typename T> ION_API
222 const Point<3, T>& eye,
const Point<3, T>& center,
const Vector<3, T>& up);
227 template <
typename T> ION_API
229 const Point<3, T>& eye,
const Vector<3, T>& dir,
const Vector<3, T>& up);
241 template <
typename T> ION_API
243 T x_left,
T x_right,
T y_bottom,
T y_top,
T z_near,
T z_far);
249 template <
typename T> ION_API
251 T x_left,
T x_right,
T y_bottom,
T y_top,
T z_near,
T z_far);
257 template <
typename T> ION_API
272 template <
typename T>
278 #endif // ION_MATH_TRANSFORMUTILS_H_
static const Vector Zero()
Returns a Vector containing all zeroes.
const Matrix< 4, T > RotationMatrixAxisAngleH(const Vector< 3, T > &axis, const Angle< T > &angle)
Returns a 4x4 Matrix representing a 3D rotation specified as axis and angle.
ION_API const Matrix< 4, T > RotationMatrixH(const Rotation< T > &r)
Returns a 4x4 Matrix representing a 3D rotation.
A simple class to represent angles.
ION_API const Matrix< 4, T > LookAtMatrixFromDir(const Point< 3, T > &eye, const Vector< 3, T > &dir, const Vector< 3, T > &up)
Returns a 4x4 viewing matrix based on the given camera parameters, which use a view direction rather ...
ION_API const Matrix< 4, T > LookAtMatrixFromCenter(const Point< 3, T > &eye, const Point< 3, T > ¢er, const Vector< 3, T > &up)
View matrices.
The Matrix class defines a square N-dimensional matrix.
ION_API const Matrix< 4, T > PerspectiveMatrixFromFrustum(T x_left, T x_right, T y_bottom, T y_top, T z_near, T z_far)
Returns a 4x4 perspective projection matrix based on the given parameters, which follow the conventio...
const Matrix< Dimension, T > ScaleMatrixNH(const Vector< Dimension, T > &s)
Returns a Matrix representing a scale by the factors in a Vector, which is the same Dimension as the ...
const Point< Dimension, T > ProjectPoint(const Matrix< Dimension+1, T > &m, const Point< Dimension, T > &p)
Multiplies a Matrix and a Point of one smaller Dimension (the template parameter) to produce another ...
const Matrix< Dimension+1, T > TranslationMatrix(const VectorBase< Dimension, T > &t)
Affine transformation matrices.
ION_API const Matrix< 3, T > RotationMatrixNH(const Rotation< T > &r)
Returns a 3x3 Matrix representing a 3D rotation.
ION_API const Matrix< 4, T > PerspectiveMatrixFromView(const Angle< T > &fovy, T aspect, T z_near, T z_far)
Returns a 4x4 perspective projection matrix based on the given parameters, which follow the conventio...
Vector< Dimension, T > operator*(const Matrix< Dimension, T > &m, const Vector< Dimension, T > &v)
Multiplies a Matrix and a column Vector of the same Dimension to produce another column Vector...
const Matrix< 4, T > OrthoInverseH(const Matrix< 4, T > &m)
Public functions.
The Rotation class represents a rotation around a 3-dimensional axis.
const Matrix< Dimension+1, T > ScaleMatrixH(const Vector< Dimension, T > &s)
Returns a Matrix representing a scale by the factors in a Vector whose Dimension is one less than the...
ION_API const Matrix< 4, T > OrthographicMatrixFromFrustum(T x_left, T x_right, T y_bottom, T y_top, T z_near, T z_far)
Projection matrices.
ION_API const Matrix< 4, T > PerspectiveMatrixInverse(const Matrix< 4, T > &m)
Returns the inverse of m iff m is a perspective projection matrix, i.e., iff it has the following for...
static const Point Zero()
Returns a Point containing all zeroes.
const Matrix< 3, T > RotationMatrixAxisAngleNH(const Vector< 3, T > &axis, const Angle< T > &angle)
Returns a 3x3 Matrix representing a 3D rotation specified as axis and angle.
Matrix< 3, T > NonhomogeneousSubmatrixH(const Matrix< 4, T > &m)
Homogeneous matrices.