#ifndef ANDROID_DVR_EIGEN_H_ #define ANDROID_DVR_EIGEN_H_ #include #include namespace Eigen { // Eigen doesn't take advantage of C++ template typedefs, but we can template using Vector = Matrix; template using Vector2 = Vector; template using Vector3 = Vector; template using Vector4 = Vector; template using RowVector = Matrix; template using RowVector2 = RowVector; template using RowVector3 = RowVector; template using RowVector4 = RowVector; // In Eigen, the type you should be using for transformation matrices is the // `Transform` class, instead of a raw `Matrix`. // The `Projective` option means this will not make any assumptions about the // last row of the object, making this suitable for use as general OpenGL // projection matrices (which is the most common use-case). The one caveat // is that in order to apply this transformation to non-homogeneous vectors // (e.g., vec3), you must use the `.linear()` method to get the affine part of // the matrix. // // Example: // mat4 transform; // vec3 position; // vec3 transformed = transform.linear() * position; // // Note, the use of N-1 is because the parameter passed to Eigen is the ambient // dimension of the transformation, not the size of the matrix iself. // However graphics programmers sometimes get upset when they see a 3 next // to a matrix when they expect a 4, so I'm hoping this will avoid that. template using AffineMatrix = Transform; } // namespace Eigen #endif // ANDROID_DVR_EIGEN_H_