Blender V4.3
BLI_math_matrix.hh File Reference

Go to the source code of this file.

Namespaces

namespace  blender
 
namespace  blender::math
 
namespace  blender::math::projection
 
namespace  blender::math::detail
 

Functions

template<typename T >
MatBase< T, 4, 4 > blender::math::projection::orthographic (T left, T right, T bottom, T top, T near_clip, T far_clip)
 Create an orthographic projection matrix using OpenGL coordinate convention: Maps each axis range to [-1..1] range for all axes. The resulting matrix can be used with either project_point or transform_point.
 
template<typename T >
MatBase< T, 4, 4 > blender::math::projection::orthographic_infinite (T left, T right, T bottom, T top)
 Create an orthographic projection matrix using OpenGL coordinate convention: Maps each axis range to [-1..1] range for all axes except Z. The Z axis is almost collapsed to 0 which eliminates the depth component. So it should not be used with depth testing. The resulting matrix can be used with either project_point or transform_point.
 
template<typename T >
MatBase< T, 4, 4 > blender::math::projection::perspective (T left, T right, T bottom, T top, T near_clip, T far_clip)
 Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-1..1] range for all axes. left, right, bottom, top are frustum side distances at z=near_clip. The resulting matrix can be used with project_point.
 
template<typename T >
MatBase< T, 4, 4 > blender::math::projection::perspective_fov (T angle_left, T angle_right, T angle_bottom, T angle_top, T near_clip, T far_clip)
 Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-1..1] range for all axes. Uses field of view angles instead of plane distances. The resulting matrix can be used with project_point.
 
template<typename T >
MatBase< T, 4, 4 > blender::math::projection::perspective_infinite (T left, T right, T bottom, T top, T near_clip)
 Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-1..1] range for all axes except for the Z where [near_clip..inf] is mapped to [-1..1]. left, right, bottom, top are frustum side distances at z=near_clip. The resulting matrix can be used with project_point.
 
template<typename T >
MatBase< T, 4, 4 > blender::math::projection::translate (const MatBase< T, 4, 4 > &mat, const VecBase< T, 2 > &offset)
 Translate a projection matrix after creation in the screen plane. Usually used for anti-aliasing jittering. offset is the translation vector in projected space.
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::detail::from_rotation (const AngleRadianBase< T > &rotation)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::detail::from_rotation (const EulerXYZBase< T > &rotation)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::detail::from_rotation (const Euler3Base< T > &rotation)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::detail::from_rotation (const QuaternionBase< T > &rotation)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::detail::from_rotation (const DualQuaternionBase< T > &rotation)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::detail::from_rotation (const CartesianBasis &rotation)
 
template<typename T , int NumCol, int NumRow, typename AngleT >
MatBase< T, NumCol, NumRow > blender::math::detail::from_rotation (const AxisAngleBase< T, AngleT > &rotation)
 
template<typename T >
AngleRadianBase< Tblender::math::detail::normalized_to_angle (const MatBase< T, 2, 2 > &mat)
 
template<typename T >
void blender::math::detail::normalized_to_eul2 (const MatBase< T, 3, 3 > &mat, EulerXYZBase< T > &eul1, EulerXYZBase< T > &eul2)
 
template<typename T >
void blender::math::detail::normalized_to_eul2 (const MatBase< T, 3, 3 > &mat, Euler3Base< T > &eul1, Euler3Base< T > &eul2)
 
template void blender::math::detail::normalized_to_eul2 (const float3x3 &mat, Euler3Base< float > &eul1, Euler3Base< float > &eul2)
 
template void blender::math::detail::normalized_to_eul2 (const float3x3 &mat, EulerXYZBase< float > &eul1, EulerXYZBase< float > &eul2)
 
template void blender::math::detail::normalized_to_eul2 (const double3x3 &mat, EulerXYZBase< double > &eul1, EulerXYZBase< double > &eul2)
 
template<typename T >
QuaternionBase< Tblender::math::detail::normalized_to_quat_fast (const MatBase< T, 3, 3 > &mat)
 
template<typename T >
QuaternionBase< Tblender::math::detail::normalized_to_quat_with_checks (const MatBase< T, 3, 3 > &mat)
 
template QuaternionBase< floatblender::math::detail::normalized_to_quat_with_checks (const float3x3 &mat)
 
template QuaternionBase< doubleblender::math::detail::normalized_to_quat_with_checks (const double3x3 &mat)
 
template MatBase< float, 2, 2 > blender::math::detail::from_rotation (const AngleRadian &rotation)
 
template MatBase< float, 3, 3 > blender::math::detail::from_rotation (const EulerXYZ &rotation)
 
template MatBase< float, 3, 3 > blender::math::detail::from_rotation (const Euler3 &rotation)
 
template MatBase< float, 3, 3 > blender::math::detail::from_rotation (const Quaternion &rotation)
 
template MatBase< float, 3, 3 > blender::math::detail::from_rotation (const AxisAngle &rotation)
 
template MatBase< float, 3, 3 > blender::math::detail::from_rotation (const AxisAngleCartesian &rotation)
 
template<typename T >
void blender::math::detail::to_rotation (const MatBase< T, 2, 2 > &mat, AngleRadianBase< T > &r_rotation)
 
template<typename T >
void blender::math::detail::to_rotation (const MatBase< T, 3, 3 > &mat, QuaternionBase< T > &r_rotation)
 
template<typename T >
void blender::math::detail::to_rotation (const MatBase< T, 3, 3 > &mat, EulerXYZBase< T > &r_rotation)
 
template<typename T >
void blender::math::detail::to_rotation (const MatBase< T, 3, 3 > &mat, Euler3Base< T > &r_rotation)
 
template<typename T >
MatBase< T, 4, 4 > blender::math::projection::orthographic_infinite (T left, T right, T bottom, T top, T near_clip)
 
template float4x4 blender::math::projection::orthographic (float left, float right, float bottom, float top, float near_clip, float far_clip)
 
template float4x4 blender::math::projection::perspective (float left, float right, float bottom, float top, float near_clip, float far_clip)
 
Matrix Operations
template<typename T , int Size>
MatBase< T, Size, Size > blender::math::invert (const MatBase< T, Size, Size > &mat, bool &r_success)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::transpose (const MatBase< T, NumRow, NumCol > &mat)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::normalize (const MatBase< T, NumCol, NumRow > &a)
 
template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::normalize_and_get_size (const MatBase< T, NumCol, NumRow > &a, VectorT &r_size)
 
template<typename T , int Size>
T blender::math::determinant (const MatBase< T, Size, Size > &mat)
 
template<typename T , int Size>
MatBase< T, Size, Size > blender::math::adjoint (const MatBase< T, Size, Size > &mat)
 
template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::translate (const MatBase< T, NumCol, NumRow > &mat, const VectorT &translation)
 
template<typename T , int NumCol, int NumRow, typename RotationT >
MatBase< T, NumCol, NumRow > blender::math::rotate (const MatBase< T, NumCol, NumRow > &mat, const RotationT &rotation)
 
template<typename T , int NumCol, int NumRow, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::scale (const MatBase< T, NumCol, NumRow > &mat, const VectorT &scale)
 
template<typename T , int NumCol, int NumRow>
MatBase< T, NumCol, NumRow > blender::math::interpolate_linear (const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, T t)
 
template<typename T >
MatBase< T, 3, 3 > blender::math::interpolate (const MatBase< T, 3, 3 > &a, const MatBase< T, 3, 3 > &b, T t)
 
template<typename T >
MatBase< T, 4, 4 > blender::math::interpolate (const MatBase< T, 4, 4 > &a, const MatBase< T, 4, 4 > &b, T t)
 
template<typename T >
MatBase< T, 3, 3 > blender::math::interpolate_fast (const MatBase< T, 3, 3 > &a, const MatBase< T, 3, 3 > &b, T t)
 
template<typename T >
MatBase< T, 4, 4 > blender::math::interpolate_fast (const MatBase< T, 4, 4 > &a, const MatBase< T, 4, 4 > &b, T t)
 
template<typename T , int Size>
MatBase< T, Size, Size > blender::math::pseudo_invert (const MatBase< T, Size, Size > &mat, T epsilon=1e-8)
 
Init helpers.
template<typename MatT >
MatT blender::math::from_location (const typename MatT::loc_type &location)
 
template<typename MatT , int ScaleDim>
MatT blender::math::from_scale (const VecBase< typename MatT::base_type, ScaleDim > &scale)
 
template<typename MatT , typename RotationT >
MatT blender::math::from_rotation (const RotationT &rotation)
 
template<typename MatT , typename RotationT , typename VectorT >
MatT blender::math::from_rot_scale (const RotationT &rotation, const VectorT &scale)
 
template<typename MatT , typename RotationT >
MatT blender::math::from_loc_rot (const typename MatT::loc_type &location, const RotationT &rotation)
 
template<typename MatT , int ScaleDim>
MatT blender::math::from_loc_scale (const typename MatT::loc_type &location, const VecBase< typename MatT::base_type, ScaleDim > &scale)
 
template<typename MatT , typename RotationT , int ScaleDim>
MatT blender::math::from_loc_rot_scale (const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
 
template<typename MatT , typename VectorT >
MatT blender::math::from_orthonormal_axes (const VectorT forward, const VectorT up)
 
template<typename MatT , typename VectorT >
MatT blender::math::from_orthonormal_axes (const VectorT location, const VectorT forward, const VectorT up)
 
template<typename MatT , typename VectorT >
MatT blender::math::from_up_axis (const VectorT up)
 
template<typename MatT >
MatT blender::math::orthogonalize (const MatT &mat, const Axis axis)
 
template<typename MatT , typename VectorT >
MatT blender::math::from_origin_transform (const MatT &transform, const VectorT origin)
 
Conversion function.
template<typename T >
AngleRadianBase< Tblender::math::to_angle (const MatBase< T, 2, 2 > &mat)
 
template<typename T >
EulerXYZBase< Tblender::math::to_euler (const MatBase< T, 3, 3 > &mat)
 
template<typename T >
EulerXYZBase< Tblender::math::to_euler (const MatBase< T, 4, 4 > &mat)
 
template<typename T >
Euler3Base< Tblender::math::to_euler (const MatBase< T, 3, 3 > &mat, EulerOrder order)
 
template<typename T >
Euler3Base< Tblender::math::to_euler (const MatBase< T, 4, 4 > &mat, EulerOrder order)
 
template<typename T >
EulerXYZBase< Tblender::math::to_nearest_euler (const MatBase< T, 3, 3 > &mat, const EulerXYZBase< T > &reference)
 
template<typename T >
EulerXYZBase< Tblender::math::to_nearest_euler (const MatBase< T, 4, 4 > &mat, const EulerXYZBase< T > &reference)
 
template<typename T >
Euler3Base< Tblender::math::to_nearest_euler (const MatBase< T, 3, 3 > &mat, const Euler3Base< T > &reference)
 
template<typename T >
Euler3Base< Tblender::math::to_nearest_euler (const MatBase< T, 4, 4 > &mat, const Euler3Base< T > &reference)
 
template<typename T >
QuaternionBase< Tblender::math::to_quaternion (const MatBase< T, 3, 3 > &mat)
 
template<typename T >
QuaternionBase< Tblender::math::to_quaternion (const MatBase< T, 4, 4 > &mat)
 
Quaternion blender::math::to_quaternion_legacy (const float3x3 &mat)
 
template<bool AllowNegativeScale = false, typename T , int NumCol, int NumRow>
VecBase< T, 3 > blender::math::to_scale (const MatBase< T, NumCol, NumRow > &mat)
 
template<bool AllowNegativeScale = false, typename T >
VecBase< T, 2 > blender::math::to_scale (const MatBase< T, 2, 2 > &mat)
 
template<bool AllowNegativeScale = false, typename T >
void blender::math::to_rot_scale (const MatBase< T, 2, 2 > &mat, AngleRadianBase< T > &r_rotation, VecBase< T, 2 > &r_scale)
 
template<bool AllowNegativeScale = false, typename T >
void blender::math::to_loc_rot_scale (const MatBase< T, 3, 3 > &mat, VecBase< T, 2 > &r_location, AngleRadianBase< T > &r_rotation, VecBase< T, 2 > &r_scale)
 
template<bool AllowNegativeScale = false, typename T , typename RotationT >
void blender::math::to_rot_scale (const MatBase< T, 3, 3 > &mat, RotationT &r_rotation, VecBase< T, 3 > &r_scale)
 
template<bool AllowNegativeScale = false, typename T , typename RotationT >
void blender::math::to_loc_rot_scale (const MatBase< T, 4, 4 > &mat, VecBase< T, 3 > &r_location, RotationT &r_rotation, VecBase< T, 3 > &r_scale)
 
Transform functions.
template<typename T >
VecBase< T, 3 > blender::math::transform_point (const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &point)
 
template<typename T >
VecBase< T, 3 > blender::math::transform_point (const MatBase< T, 4, 4 > &mat, const VecBase< T, 3 > &point)
 
template<typename T >
VecBase< T, 3 > blender::math::transform_direction (const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
 
template<typename T >
VecBase< T, 3 > blender::math::transform_direction (const MatBase< T, 4, 4 > &mat, const VecBase< T, 3 > &direction)
 
template<typename MatT , typename VectorT >
VectorT blender::math::project_point (const MatT &mat, const VectorT &point)
 
Compare / Test
template<typename T , int Size>
bool blender::math::is_negative (const MatBase< T, Size, Size > &mat)
 
template<typename T >
bool blender::math::is_negative (const MatBase< T, 4, 4 > &mat)
 
template<typename T , int NumCol, int NumRow>
bool blender::math::is_equal (const MatBase< T, NumCol, NumRow > &a, const MatBase< T, NumCol, NumRow > &b, const T epsilon=T(0))
 
template<typename MatT >
bool blender::math::is_orthogonal (const MatT &mat)
 
template<typename MatT >
bool blender::math::is_orthonormal (const MatT &mat)
 
template<typename MatT >
bool blender::math::is_uniformly_scaled (const MatT &mat)
 
template<typename T , int NumCol, int NumRow>
bool blender::math::is_zero (const MatBase< T, NumCol, NumRow > &mat)
 
Implementation.
template<typename T , int NumCol, int NumRow>
bool blender::math::is_unit_scale (const MatBase< T, NumCol, NumRow > &m)
 
template<typename T , int Size>
MatBase< T, Size, Size > blender::math::invert (const MatBase< T, Size, Size > &mat)
 
template<typename T , int NumCol, int NumRow, typename AngleT >
MatBase< T, NumCol, NumRow > blender::math::rotate (const MatBase< T, NumCol, NumRow > &mat, const AxisAngleBase< T, AngleT > &rotation)
 
template<typename T , int NumCol, int NumRow, int SrcNumCol, int SrcNumRow, int SrcStartCol, int SrcStartRow, int SrcAlignment>
MatBase< T, NumCol, NumRow > blender::math::normalize (const MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment > &a)
 
template<typename T , int NumCol, int NumRow, int SrcNumCol, int SrcNumRow, int SrcStartCol, int SrcStartRow, int SrcAlignment, typename VectorT >
MatBase< T, NumCol, NumRow > blender::math::normalize_and_get_size (const MatView< T, NumCol, NumRow, SrcNumCol, SrcNumRow, SrcStartCol, SrcStartRow, SrcAlignment > &a, VectorT &r_size)
 
template<typename T >
QuaternionBase< Tblender::math::normalized_to_quaternion_safe (const MatBase< T, 3, 3 > &mat)
 
template<bool AllowNegativeScale, typename T , typename RotationT >
void blender::math::to_loc_rot_scale_safe (const MatBase< T, 4, 4 > &mat, VecBase< T, 3 > &r_location, RotationT &r_rotation, VecBase< T, 3 > &r_scale)
 
template<typename T , int N, int NumRow>
VecBase< T, Nblender::math::project_point (const MatBase< T, N+1, NumRow > &mat, const VecBase< T, N > &point)
 
template float3 blender::math::transform_point (const float3x3 &mat, const float3 &point)
 
template float3 blender::math::transform_point (const float4x4 &mat, const float3 &point)
 
template float3 blender::math::transform_direction (const float3x3 &mat, const float3 &direction)
 
template float3 blender::math::transform_direction (const float4x4 &mat, const float3 &direction)
 
template float3 blender::math::project_point (const float4x4 &mat, const float3 &point)
 
template float2 blender::math::project_point (const float3x3 &mat, const float2 &point)