GfMatrix2f Class Reference

Stores a 2x2 matrix of float elements. More...

Public Types

typedef float ScalarType
 

Public Member Functions

 GfMatrix2f ()=default
 Default constructor. Leaves the matrix component values undefined. More...
 
 GfMatrix2f (float m00, float m01, float m10, float m11)
 Constructor. More...
 
 GfMatrix2f (const float m[2][2])
 Constructor. More...
 
 GfMatrix2f (float s)
 Constructor. More...
 
 GfMatrix2f (int s)
 This explicit constructor initializes the matrix to s times the identity matrix. More...
 
 GfMatrix2f (const GfVec2f &v)
 Constructor. More...
 
GF_API GfMatrix2f (const std::vector< std::vector< double > > &v)
 Constructor. More...
 
GF_API GfMatrix2f (const std::vector< std::vector< float > > &v)
 Constructor. More...
 
GF_API GfMatrix2f (const class GfMatrix2d &m)
 This explicit constructor converts a "double" matrix to a "float" matrix. More...
 
void SetRow (int i, const GfVec2f &v)
 Sets a row of the matrix from a Vec2. More...
 
void SetColumn (int i, const GfVec2f &v)
 Sets a column of the matrix from a Vec2. More...
 
GfVec2f GetRow (int i) const
 Gets a row of the matrix as a Vec2. More...
 
GfVec2f GetColumn (int i) const
 Gets a column of the matrix as a Vec2. More...
 
GfMatrix2fSet (float m00, float m01, float m10, float m11)
 Sets the matrix from 4 independent float values, specified in row-major order. More...
 
GfMatrix2fSet (const float m[2][2])
 Sets the matrix from a 2x2 array of float values, specified in row-major order. More...
 
GfMatrix2fSetIdentity ()
 Sets the matrix to the identity matrix. More...
 
GfMatrix2fSetZero ()
 Sets the matrix to zero. More...
 
GF_API GfMatrix2fSetDiagonal (float s)
 Sets the matrix to s times the identity matrix. More...
 
GF_API GfMatrix2fSetDiagonal (const GfVec2f &)
 Sets the matrix to have diagonal (v[0], v[1]). More...
 
GF_API float * Get (float m[2][2]) const
 Fills a 2x2 array of float values with the values in the matrix, specified in row-major order. More...
 
float * data ()
 Returns raw access to components of matrix as an array of float values. More...
 
const float * data () const
 Returns const raw access to components of matrix as an array of float values. More...
 
float * GetArray ()
 Returns vector components as an array of float values. More...
 
const float * GetArray () const
 Returns vector components as a const array of float values. More...
 
float * operator [] (int i)
 Accesses an indexed row i of the matrix as an array of 2 float values so that standard indexing (such as m[0][1]) works correctly. More...
 
const float * operator [] (int i) const
 Accesses an indexed row i of the matrix as an array of 2 float values so that standard indexing (such as m[0][1]) works correctly. More...
 
GF_API bool operator== (const GfMatrix2d &m) const
 Tests for element-wise matrix equality. More...
 
GF_API bool operator== (const GfMatrix2f &m) const
 Tests for element-wise matrix equality. More...
 
bool operator != (const GfMatrix2d &m) const
 Tests for element-wise matrix inequality. More...
 
bool operator != (const GfMatrix2f &m) const
 Tests for element-wise matrix inequality. More...
 
GF_API GfMatrix2f GetTranspose () const
 Returns the transpose of the matrix. More...
 
GF_API GfMatrix2f GetInverse (double *det=NULL, double eps=0) const
 Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular. More...
 
GF_API double GetDeterminant () const
 Returns the determinant of the matrix. More...
 
GF_API GfMatrix2foperator *= (const GfMatrix2f &m)
 Post-multiplies matrix m into this matrix. More...
 
GF_API GfMatrix2foperator *= (double)
 Multiplies the matrix by a float. More...
 
GF_API GfMatrix2foperator+= (const GfMatrix2f &m)
 Adds matrix m to this matrix. More...
 
GF_API GfMatrix2foperator -= (const GfMatrix2f &m)
 Subtracts matrix m from this matrix. More...
 

Static Public Attributes

static const size_t numRows = 2
 
static const size_t numColumns = 2
 

Friends

class GfMatrix2d
 
size_t hash_value (GfMatrix2f const &m)
 Hash. More...
 
GfMatrix2f operator * (const GfMatrix2f &m1, double d)
 Returns the product of a matrix and a float. More...
 
GfMatrix2f operator * (double d, const GfMatrix2f &m)
 
GF_API friend GfMatrix2f operator - (const GfMatrix2f &m)
 Returns the unary negation of matrix m. More...
 
GfMatrix2f operator+ (const GfMatrix2f &m1, const GfMatrix2f &m2)
 Adds matrix m2 to m1. More...
 
GfMatrix2f operator - (const GfMatrix2f &m1, const GfMatrix2f &m2)
 Subtracts matrix m2 from m1. More...
 
GfMatrix2f operator * (const GfMatrix2f &m1, const GfMatrix2f &m2)
 Multiplies matrix m1 by m2. More...
 
GfMatrix2f operator/ (const GfMatrix2f &m1, const GfMatrix2f &m2)
 Divides matrix m1 by m2 (that is, m1 * inv(m2)). More...
 
GfVec2f operator * (const GfMatrix2f &m, const GfVec2f &vec)
 Returns the product of a matrix m and a column vector vec. More...
 
GfVec2f operator * (const GfVec2f &vec, const GfMatrix2f &m)
 Returns the product of row vector vec and a matrix m. More...
 

Detailed Description

Stores a 2x2 matrix of float elements.

A basic type.

Matrices are defined to be in row-major order, so matrix[i][j] indexes the element in the i th row and the j th column.

Definition at line 62 of file matrix2f.h.

Constructor & Destructor Documentation

◆ GfMatrix2f() [1/9]

GfMatrix2f ( )
default

Default constructor. Leaves the matrix component values undefined.

◆ GfMatrix2f() [2/9]

GfMatrix2f ( float  m00,
float  m01,
float  m10,
float  m11 
)
inline

Constructor.

Initializes the matrix from 4 independent float values, specified in row-major order. For example, parameter m10 specifies the value in row 1 and column 0.

Definition at line 76 of file matrix2f.h.

◆ GfMatrix2f() [3/9]

GfMatrix2f ( const float  m[2][2])
inline

Constructor.

Initializes the matrix from a 2x2 array of float values, specified in row-major order.

Definition at line 84 of file matrix2f.h.

◆ GfMatrix2f() [4/9]

GfMatrix2f ( float  s)
inlineexplicit

Constructor.

Explicitly initializes the matrix to s times the identity matrix.

Definition at line 90 of file matrix2f.h.

◆ GfMatrix2f() [5/9]

GfMatrix2f ( int  s)
inlineexplicit

This explicit constructor initializes the matrix to s times the identity matrix.

Definition at line 96 of file matrix2f.h.

◆ GfMatrix2f() [6/9]

GfMatrix2f ( const GfVec2f v)
inlineexplicit

Constructor.

Explicitly initializes the matrix to diagonal form, with the i th element on the diagonal set to v[i].

Definition at line 102 of file matrix2f.h.

◆ GfMatrix2f() [7/9]

GF_API GfMatrix2f ( const std::vector< std::vector< double > > &  v)
explicit

Constructor.

Initialize the matrix from a vector of vectors of double. The vector is expected to be 2x2. If it is too big, only the first 2 rows and/or columns will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.

◆ GfMatrix2f() [8/9]

GF_API GfMatrix2f ( const std::vector< std::vector< float > > &  v)
explicit

Constructor.

Initialize the matrix from a vector of vectors of float. The vector is expected to be 2x2. If it is too big, only the first 2 rows and/or columns will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.

◆ GfMatrix2f() [9/9]

GF_API GfMatrix2f ( const class GfMatrix2d m)
explicit

This explicit constructor converts a "double" matrix to a "float" matrix.

Member Function Documentation

◆ data() [1/2]

float* data ( )
inline

Returns raw access to components of matrix as an array of float values.

Components are in row-major order.

Definition at line 195 of file matrix2f.h.

◆ data() [2/2]

const float* data ( ) const
inline

Returns const raw access to components of matrix as an array of float values.

Components are in row-major order.

Definition at line 201 of file matrix2f.h.

◆ Get()

GF_API float* Get ( float  m[2][2]) const

Fills a 2x2 array of float values with the values in the matrix, specified in row-major order.

◆ GetArray() [1/2]

float* GetArray ( )
inline

Returns vector components as an array of float values.

Definition at line 206 of file matrix2f.h.

◆ GetArray() [2/2]

const float* GetArray ( ) const
inline

Returns vector components as a const array of float values.

Definition at line 211 of file matrix2f.h.

◆ GetColumn()

GfVec2f GetColumn ( int  i) const
inline

Gets a column of the matrix as a Vec2.

Definition at line 146 of file matrix2f.h.

◆ GetDeterminant()

GF_API double GetDeterminant ( ) const

Returns the determinant of the matrix.

◆ GetInverse()

GF_API GfMatrix2f GetInverse ( double *  det = NULL,
double  eps = 0 
) const

Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular.

(FLT_MAX is the largest value a float can have, as defined by the system.) The matrix is considered singular if the determinant is less than or equal to the optional parameter eps. If det is non-null, *det is set to the determinant.

◆ GetRow()

GfVec2f GetRow ( int  i) const
inline

Gets a row of the matrix as a Vec2.

Definition at line 141 of file matrix2f.h.

◆ GetTranspose()

GF_API GfMatrix2f GetTranspose ( ) const

Returns the transpose of the matrix.

◆ operator !=() [1/2]

bool operator != ( const GfMatrix2d m) const
inline

Tests for element-wise matrix inequality.

All elements must match exactly for matrices to be considered equal.

Definition at line 247 of file matrix2f.h.

◆ operator !=() [2/2]

bool operator != ( const GfMatrix2f m) const
inline

Tests for element-wise matrix inequality.

All elements must match exactly for matrices to be considered equal.

Definition at line 253 of file matrix2f.h.

◆ operator *=() [1/2]

GF_API GfMatrix2f& operator *= ( const GfMatrix2f m)

Post-multiplies matrix m into this matrix.

◆ operator *=() [2/2]

GF_API GfMatrix2f& operator *= ( double  )

Multiplies the matrix by a float.

◆ operator -=()

GF_API GfMatrix2f& operator -= ( const GfMatrix2f m)

Subtracts matrix m from this matrix.

◆ operator []() [1/2]

float* operator [] ( int  i)
inline

Accesses an indexed row i of the matrix as an array of 2 float values so that standard indexing (such as m[0][1]) works correctly.

Definition at line 218 of file matrix2f.h.

◆ operator []() [2/2]

const float* operator [] ( int  i) const
inline

Accesses an indexed row i of the matrix as an array of 2 float values so that standard indexing (such as m[0][1]) works correctly.

Definition at line 223 of file matrix2f.h.

◆ operator+=()

GF_API GfMatrix2f& operator+= ( const GfMatrix2f m)

Adds matrix m to this matrix.

◆ operator==() [1/2]

GF_API bool operator== ( const GfMatrix2d m) const

Tests for element-wise matrix equality.

All elements must match exactly for matrices to be considered equal.

◆ operator==() [2/2]

GF_API bool operator== ( const GfMatrix2f m) const

Tests for element-wise matrix equality.

All elements must match exactly for matrices to be considered equal.

◆ Set() [1/2]

GfMatrix2f& Set ( float  m00,
float  m01,
float  m10,
float  m11 
)
inline

Sets the matrix from 4 independent float values, specified in row-major order.

For example, parameter m10 specifies the value in row 1 and column 0.

Definition at line 153 of file matrix2f.h.

◆ Set() [2/2]

GfMatrix2f& Set ( const float  m[2][2])
inline

Sets the matrix from a 2x2 array of float values, specified in row-major order.

Definition at line 162 of file matrix2f.h.

◆ SetColumn()

void SetColumn ( int  i,
const GfVec2f v 
)
inline

Sets a column of the matrix from a Vec2.

Definition at line 135 of file matrix2f.h.

◆ SetDiagonal() [1/2]

GF_API GfMatrix2f& SetDiagonal ( float  s)

Sets the matrix to s times the identity matrix.

◆ SetDiagonal() [2/2]

GF_API GfMatrix2f& SetDiagonal ( const GfVec2f )

Sets the matrix to have diagonal (v[0], v[1]).

◆ SetIdentity()

GfMatrix2f& SetIdentity ( )
inline

Sets the matrix to the identity matrix.

Definition at line 171 of file matrix2f.h.

◆ SetRow()

void SetRow ( int  i,
const GfVec2f v 
)
inline

Sets a row of the matrix from a Vec2.

Definition at line 129 of file matrix2f.h.

◆ SetZero()

GfMatrix2f& SetZero ( )
inline

Sets the matrix to zero.

Definition at line 176 of file matrix2f.h.

Friends And Related Function Documentation

◆ hash_value

size_t hash_value ( GfMatrix2f const &  m)
friend

Hash.

Definition at line 226 of file matrix2f.h.

◆ operator * [1/4]

GfMatrix2f operator * ( const GfMatrix2f m1,
double  d 
)
friend

Returns the product of a matrix and a float.

Definition at line 283 of file matrix2f.h.

◆ operator * [2/4]

GfMatrix2f operator * ( const GfMatrix2f m1,
const GfMatrix2f m2 
)
friend

Multiplies matrix m1 by m2.

Definition at line 325 of file matrix2f.h.

◆ operator * [3/4]

GfVec2f operator * ( const GfMatrix2f m,
const GfVec2f vec 
)
friend

Returns the product of a matrix m and a column vector vec.

Definition at line 339 of file matrix2f.h.

◆ operator * [4/4]

GfVec2f operator * ( const GfVec2f vec,
const GfMatrix2f m 
)
friend

Returns the product of row vector vec and a matrix m.

Definition at line 345 of file matrix2f.h.

◆ operator - [1/2]

GF_API friend GfMatrix2f operator - ( const GfMatrix2f m)
friend

Returns the unary negation of matrix m.

◆ operator - [2/2]

GfMatrix2f operator - ( const GfMatrix2f m1,
const GfMatrix2f m2 
)
friend

Subtracts matrix m2 from m1.

Definition at line 317 of file matrix2f.h.

◆ operator+

GfMatrix2f operator+ ( const GfMatrix2f m1,
const GfMatrix2f m2 
)
friend

Adds matrix m2 to m1.

Definition at line 309 of file matrix2f.h.

◆ operator/

GfMatrix2f operator/ ( const GfMatrix2f m1,
const GfMatrix2f m2 
)
friend

Divides matrix m1 by m2 (that is, m1 * inv(m2)).

Definition at line 333 of file matrix2f.h.


The documentation for this class was generated from the following file: