DD::Image::Matrix3 Class Reference

A 3x3 transformation matrix. More...

Public Member Functions

float * operator[] (int i)
 
const float * operator[] (int i) const
 
const float * array () const
 
 Matrix3 (float a, float b, float c, float d, float e, float f, float g, float h, float i)
 
void set (float a, float b, float c, float d, float e, float f, float g, float h, float i)
 
Matrix3 operator* (const Matrix3 &) const
 
Matrix3operator*= (const Matrix3 &)
 
Matrix3 operator+ (const Matrix3 &) const
 
Matrix3operator+= (const Matrix3 &)
 
Matrix3 operator- (const Matrix3 &) const
 
Matrix3operator-= (const Matrix3 &)
 
Matrix3 operator* (float) const
 
Matrix3operator*= (float)
 
Matrix3 operator/ (float d) const
 
Matrix3operator/= (float d)
 
Vector3 operator* (const Vector3 &v) const
 
Vector3 transform (const Vector3 &v) const
 
bool operator!= (const Matrix3 &b) const
 
bool operator== (const Matrix3 &b) const
 
float determinant () const
 
Matrix3 inverse (float det) const
 
Matrix3 inverse () const
 
void makeIdentity ()
 
void scaling (float)
 
void scaling (float, float, float)
 
void scaling (const Vector3 &v)
 
void rotationX (float)
 
void rotationY (float)
 
void rotationZ (float)
 
void rotation (float a)
 
void rotation (float a, float x, float y, float z)
 
void rotation (float a, const Vector3 &v)
 
void scale (float)
 
void scale (float, float, float=1)
 
void scale (const Vector3 &v)
 
void rotateX (float)
 
void rotateY (float)
 
void rotateZ (float)
 
void rotate (float a)
 
void rotate (float a, float x, float y, float z)
 
void rotate (float a, const Vector3 &v)
 
void skew (float a)
 
void append (Hash &) const
 

Static Public Member Functions

static const Matrix3identity ()
 

Public Attributes

float a00
 
float a10
 
float a20
 
float a01
 
float a11
 
float a21
 
float a02
 
float a12
 
float a22
 

Static Public Attributes

static const Matrix3 _identity
 

Friends

std::ostream & operator<< (std::ostream &o, const Matrix3 &matrix)
 

Detailed Description

A 3x3 transformation matrix.

You multiply a Vector3 by one of these to go from one 3D space to another. This cannot represent 3D translations or perspective, use a Matrix4 for that. This is also often used to transform color spaces.

The data is stored packed together in OpenGL order, which is transposed from the way used in most modern graphics literature. This affects how the array() and [] operator work, these are all equal:

  • matrix.a12
  • matrix[2][1]
  • matrix.array()[1+3*2]

Constructor & Destructor Documentation

DD::Image::Matrix3::Matrix3 ( float  a,
float  b,
float  c,
float  d,
float  e,
float  f,
float  g,
float  h,
float  i 
)
inline

Initialize with a00=a, a01=b, a02=c, etc, ie the arguments are given as rows.

Member Function Documentation

float * DD::Image::Matrix3::operator[] ( int  i)
inline

Return a pointer to the column number i.

const float * DD::Image::Matrix3::operator[] ( int  i) const
inline

Return a pointer to the column number i.

const float * DD::Image::Matrix3::array ( ) const
inline

Return a pointer to a00. This array is in the correct order to send it to OpenGL.

Matrix3 Matrix3::operator* ( const Matrix3 B) const

Does matrix multiplication.

Matrix3 & Matrix3::operator*= ( const Matrix3 B)

Does matrix multiplication.

Matrix3 Matrix3::operator+ ( const Matrix3 B) const

Add each matching locations.

Matrix3 & Matrix3::operator+= ( const Matrix3 B)

Add each matching locations.

Matrix3 Matrix3::operator- ( const Matrix3 B) const

Subtract each matching locations.

Matrix3 & Matrix3::operator-= ( const Matrix3 B)

Subtract each matching locations.

Matrix3 Matrix3::operator* ( float  f) const

Multiplies every location by f.

Matrix3 & Matrix3::operator*= ( float  f)

Multiplies every location by f.

Vector3 DD::Image::Matrix3::operator* ( const Vector3 v) const
inline

Returns the transformation of v by this matrix.

Vector3 DD::Image::Matrix3::transform ( const Vector3 v) const
inline

Same as this*v

bool DD::Image::Matrix3::operator!= ( const Matrix3 b) const
inline

Returns true if any of all 9 locations are different.

bool DD::Image::Matrix3::operator== ( const Matrix3 b) const
inline

Returns true if all 9 locations are equal.

float DD::Image::Matrix3::determinant ( void  ) const
inline

Return the determinant. Non-zero means the transformation can be inverted.

Matrix3 Matrix3::inverse ( float  det) const

Returns the inverse of this matrix where det is the precomputed determinant. This is useful if you already computed the determinant in order to see if you can invert the matrix.

Matrix3 DD::Image::Matrix3::inverse ( ) const
inline

Returns the inverse of this matrix. If determinant() is zero this will replace all the items with +/- infinity or zero.

References inverse().

Referenced by inverse().

void DD::Image::Matrix3::makeIdentity ( )
inline

Replace the contents with the identity.

void Matrix3::scaling ( float  x)

Replace the contents with a uniform scale by x.

void Matrix3::scaling ( float  x,
float  y,
float  z 
)

Replace the contents with a scale by x,y,z.

void DD::Image::Matrix3::scaling ( const Vector3 v)
inline

Replace the contents with a scale by the x,y,z of the vector.

References scaling().

Referenced by scaling().

void Matrix3::rotationX ( float  angle)

Replace the contents with a rotation by angle (in radians) around the X axis.

Referenced by rotateX().

void Matrix3::rotationY ( float  angle)

Replace the contents with a rotation by angle (in radians) around the Y axis.

Referenced by rotateY().

void Matrix3::rotationZ ( float  angle)

Replace the contents with a rotation by angle (in radians) around the Z axis.

Referenced by rotateZ().

void DD::Image::Matrix3::rotation ( float  angle)
inline

Same as rotationZ(angle).

Referenced by rotate().

void Matrix3::rotation ( float  a,
float  x,
float  y,
float  z 
)

Replace the contents with a rotation by angle (in radians) around the vector x,y,z.

void DD::Image::Matrix3::rotation ( float  angle,
const Vector3 v 
)
inline

Replace the contents with a rotation by angle (in radians) around the vector.

References rotation().

Referenced by rotation().

void Matrix3::scale ( float  s)

Scale the transformation by s.

void Matrix3::scale ( float  x,
float  y,
float  z = 1 
)

Scale the transformation by x,y,z.

void DD::Image::Matrix3::scale ( const Vector3 v)
inline

Scale the transformation by the x,y,z of the vector.

References scale().

Referenced by scale().

void Matrix3::rotateX ( float  a)

Rotate the transformation by a radians about the X axis.

References rotationX().

void Matrix3::rotateY ( float  a)

Rotate the transformation by a radians about the Y axis.

References rotationY().

void Matrix3::rotateZ ( float  a)

Rotate the transformation by a radians about the Z axis.

References rotationZ().

void DD::Image::Matrix3::rotate ( float  a)
inline

Same as rotateZ(a).

void Matrix3::rotate ( float  a,
float  x,
float  y,
float  z 
)

Rotate the transformation by a radians about the vector x,y,z.

References rotation().

void DD::Image::Matrix3::rotate ( float  a,
const Vector3 v 
)
inline

Rotate the transformation by a radians about the vector.

References rotate().

Referenced by rotate().

void Matrix3::skew ( float  a)

Skew the transformation by a (X positions have a*Y added to them).

void Matrix3::append ( Hash hash) const

Add this to the Hash object.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const Matrix3 matrix 
)
friend

Writes it in nuke/tcl notation, with nested curly braces



©2022 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk