Mat3< V > Struct Template Reference

#include <matrix.h>

Detailed Description

template<typename V>
struct maxon::Mat3< V >

Matrix.

The matrix has a dimension of 4×4 and consists of four rows and four columns. The first row is always "1, 0, 0, 0" and not stored in the class, which means that there are 12 actual numbers used. These numbers are grouped into four vectors, one for the remaining numbers in each column. The four vectors are called off, v1, v2 and v3, together these four vectors can be used to represent the coordinate system. A coordinate system consists of three axes, one for each coordinate (X, Y and Z). The system also has a base position, from which the three axes originate. This base position is stored in off, and the three axis vectors are stored in v1, v2 and v3 respectively. For a rectangular, normalized matrix v3 equals the cross product of v1 and v2 (v1v2). C4D by default uses a left-handed coordinate system (see define COORDINATESYSTEM_LEFT_HANDED).

Public Types

using ValueType = typename V::ValueType
 
using ValueTypeParam = typename ByValueParam< ValueType >::type
 
using BoolType = typename V::BoolType
 

Public Member Functions

constexpr Mat3 ()
 
constexpr Mat3 (const V &off_in, const V &v1_in, const V &v2_in, const V &v3_in)
 
constexpr Mat3 (const V &off_in, const SqrMat3< V > &mat_in)
 
constexpr MAXON_IMPLICIT Mat3 (const SqrMat3< V > &mat_in)
 
template<typename V2 >
constexpr Mat3 (const Mat3< V2 > &m)
 
constexpr Mat3 (ENUM_DONT_INITIALIZE v)
 
template<typename V2 >
constexpr Mat3 (const Mat2< V2 > &m)
 
constexpr void SetIdentity ()
 
template<typename V2 >
constexpr Mat3< typename MultiplicativePromotion< V, typename V2::ValueType >::type > operator* (const Mat3< V2 > &m2) const
 
template<typename V2 >
constexpr Mat3< typename MultiplicativePromotion< V, typename V2::ValueType >::type > operator* (const SqrMat3< V2 > &m2) const
 
template<typename T , Int S>
constexpr Vec3< typename MultiplicativePromotion< ValueType, T >::type, 1 > operator* (const Vec3< T, S > &v) const
 
constexpr Mat3 operator* (ValueTypeParam s) const
 
constexpr Mat3 operator/ (ValueTypeParam s) const
 
constexpr BoolType operator== (const Mat3 &other) const
 
constexpr BoolType operator!= (const Mat3 &other) const
 
constexpr Mat3 operator~ () const
 
constexpr Mat3 GetNormalized () const
 
String ToString (const FormatStatement *formatStatement=nullptr) const
 
constexpr HashInt GetHashCode () const
 

Static Public Member Functions

static constexpr const Mat3NullValue ()
 

Public Attributes

off
 
SqrMat3< V > sqmat
 

Friends

constexpr friend Mat3 operator* (ValueTypeParam s, const Mat3 &m)
 
constexpr friend Mat3 Min (const Mat3 &a, const Mat3 &other)
 
constexpr friend Mat3 Max (const Mat3 &a, const Mat3 &other)
 

Member Typedef Documentation

◆ ValueType

using ValueType = typename V::ValueType

◆ ValueTypeParam

using ValueTypeParam = typename ByValueParam<ValueType>::type

◆ BoolType

using BoolType = typename V::BoolType

The type returned by comparisons. If the template argument for V is a vector of SIMD components, this will be a SIMD type, too, which contains the per-element results.

Constructor & Destructor Documentation

◆ Mat3() [1/7]

constexpr Mat3 ( )
constexpr

Default constructor, creates an identity matrix.

◆ Mat3() [2/7]

constexpr Mat3 ( const V &  off_in,
const V &  v1_in,
const V &  v2_in,
const V &  v3_in 
)
constexpr

Initializes matrix from individual components.

◆ Mat3() [3/7]

constexpr Mat3 ( const V &  off_in,
const SqrMat3< V > &  mat_in 
)
constexpr

Initializes matrix from individual components.

◆ Mat3() [4/7]

constexpr MAXON_IMPLICIT Mat3 ( const SqrMat3< V > &  mat_in)
constexpr

Initializes matrix from square matrix. The translation part is initialized to zero.

◆ Mat3() [5/7]

constexpr Mat3 ( const Mat3< V2 > &  m)
explicitconstexpr

Initializes matrix from another matrix.

◆ Mat3() [6/7]

constexpr Mat3 ( ENUM_DONT_INITIALIZE  v)
explicitconstexpr

Skips initialization of matrix (for better speed)

◆ Mat3() [7/7]

constexpr Mat3 ( const Mat2< V2 > &  m)
explicitconstexpr

Initializes matrix from 2d matrix. v3 is assigned Cross(v1, v2).GetNormalized()

Member Function Documentation

◆ SetIdentity()

constexpr void SetIdentity ( )
constexpr

Sets this matrix to an identity matrix.

◆ operator*() [1/4]

constexpr Mat3<typename MultiplicativePromotion<V, typename V2::ValueType>::type> operator* ( const Mat3< V2 > &  m2) const
constexpr

Multiplies two matrices. The rule is m1 AFTER m2 If you transform a point with the result matrix this is identical to first transforming with m2 and then with m1

◆ operator*() [2/4]

constexpr Mat3<typename MultiplicativePromotion<V, typename V2::ValueType>::type> operator* ( const SqrMat3< V2 > &  m2) const
constexpr

Multiplies two matrices. The rule is m1 AFTER m2 If you transform a point with the result matrix this is identical to first transforming with m2 and then with m1

◆ operator*() [3/4]

constexpr Vec3<typename MultiplicativePromotion<ValueType, T>::type, 1> operator* ( const Vec3< T, S > &  v) const
constexpr

Transforms a point by a matrix.

◆ operator*() [4/4]

constexpr Mat3 operator* ( ValueTypeParam  s) const
constexpr

Scales all matrix components by a scalar value.

◆ operator/()

constexpr Mat3 operator/ ( ValueTypeParam  s) const
constexpr

Divides all matrix components by a scalar value. If s is 0.0 an identity matrix will be returned.

◆ operator==()

constexpr BoolType operator== ( const Mat3< V > &  other) const
constexpr

Equality operator.

Parameters
[in]otherComparison matrix.
Returns
True if this and other are equal, otherwise false.

◆ operator!=()

constexpr BoolType operator!= ( const Mat3< V > &  other) const
constexpr

Inequality operator.

Parameters
[in]otherComparison matrix.
Returns
False if this and other are equal, otherwise true.

◆ operator~()

constexpr Mat3 operator~ ( ) const
constexpr

Calculates the inverse matrix If no inverse can be calculated the result is the Identity matrix

◆ GetNormalized()

constexpr Mat3 GetNormalized ( ) const
constexpr

Returns this matrix with all axis vectors normalized.

◆ ToString()

String ToString ( const FormatStatement formatStatement = nullptr) const

Returns a readable string of the content.

Parameters
[in]formatStatementNullptr or additional formatting instruction. See also Formatting Floating point values.
Returns
The converted result.

◆ GetHashCode()

constexpr HashInt GetHashCode ( ) const
constexpr

Returns the hash code of the matrix (used for hash maps and comparisons).

Returns
The matrix' hash code.

◆ NullValue()

static constexpr const Mat3& NullValue ( )
staticconstexpr

Returns a null value of the matrix (see nullvalue.h for more details).

Returns
A null value of the matrix.

Friends And Related Function Documentation

◆ operator*

constexpr friend Mat3 operator* ( ValueTypeParam  s,
const Mat3< V > &  m 
)
friend

Scales all matrix components by a scalar value.

◆ Min

constexpr friend Mat3 Min ( const Mat3< V > &  a,
const Mat3< V > &  other 
)
friend

Calculates the minimum of each component.

◆ Max

constexpr friend Mat3 Max ( const Mat3< V > &  a,
const Mat3< V > &  other 
)
friend

Calculates the maximum of each component.

Member Data Documentation

◆ off

V off

The translation vector.

◆ sqmat

SqrMat3<V> sqmat

The 3×3 matrix for rotation, scale and shear.