VRay SDK for C++
Loading...
Searching...
No Matches
VRay::Matrix Struct Reference

3x3 column-major matrix, float32 More...

#include <vraysdk.hpp>

Public Member Functions

 Matrix () noexcept=default
 Constructor - initializes all components to zero.
 
 Matrix (const Matrix &) noexcept=default
 
 Matrix (const Vector &a, const Vector &b, const Vector &c) noexcept
 
 Matrix (float value) noexcept
 Constructor to diagonal matrix.
 
 Matrix (Matrix &&) noexcept=default
 
 Matrix (Vector diagonal) noexcept
 Constructor to diagonal matrix.
 
void addDiagonal (const Vector &a) noexcept
 
void addTranspose (const Matrix &b) noexcept
 
void makeDiagonal (const Vector &a) noexcept
 
void makeIdentity (void) noexcept
 Make the matrix the identity matrix.
 
bool makeInverse (void) noexcept
 
void makeOrthogonal (void) noexcept
 
void makeOrthonormal (void) noexcept
 
void makeOuterProduct (const Vector &a, const Vector &b) noexcept
 
void makeTranspose (void) noexcept
 Make the matrix to be the transpose of its currrent value.
 
void makeZero (void) noexcept
 Make the matrix the zero matrix (all elements are zeroes).
 
void operator*= (float x) noexcept
 Multiply all elements in the matrix by the given number.
 
void operator+= (const Matrix &m) noexcept
 
void operator-= (const Matrix &m) noexcept
 
void operator/= (float x) noexcept
 Divide all elements in the matrix by the given number. Does not perform a check for divide by zero.
 
Matrixoperator= (const Matrix &) noexcept=default
 
Matrixoperator= (Matrix &&) noexcept=default
 
const Vectoroperator[] (const int index) const noexcept
 Return the i-th column of the matrix as a const object (i=0,1,2).
 
Vectoroperator[] (const int index) noexcept
 Return the i-th column of the matrix (i=0,1,2).
 
void rotate (const Vector &axis) noexcept
 Applies a rotation along the given axis. The length of the axis is the tangent of the angle of rotation.
 
void set (const Matrix &other) noexcept
 
void set (const Vector &a, const Vector &b, const Vector &c) noexcept
 
void set (float value) noexcept
 Make diagonal matrix.
 
void setCol (const int i, const Vector &a) noexcept
 
void setRow (const int i, const Vector &a) noexcept
 
std::string toString () const
 

Public Attributes

Vector v0
 
Vector v1
 
Vector v2
 

Related Functions

(Note that these are not member functions.)

Matrix inverse (const Matrix &m) noexcept
 
Matrix makeRotationMatrixX (float xrot) noexcept
 
Matrix makeRotationMatrixY (float yrot) noexcept
 
Matrix makeRotationMatrixZ (float zrot) noexcept
 
Matrix normalize (const Matrix &m) noexcept
 
Matrix noScale (const Matrix &m) noexcept
 
bool operator!= (const Matrix &a, const Matrix &b) noexcept
 
Matrix operator* (const Matrix &a, const Matrix &b) noexcept
 
Vector operator* (const Matrix &m, const Vector &a) noexcept
 
Matrix operator* (const Matrix &m, float x) noexcept
 
Vector operator* (const Vector &a, const Matrix &m) noexcept
 
Matrix operator* (float x, const Matrix &m) noexcept
 
Matrix operator+ (const Matrix &a, const Matrix &b) noexcept
 
Matrix operator- (const Matrix &a) noexcept
 
Matrix operator- (const Matrix &a, const Matrix &b) noexcept
 
Matrix operator/ (const Matrix &m, float x) noexcept
 
float operator/ (float x, const Matrix &m) noexcept
 
bool operator== (const Matrix &a, const Matrix &b) noexcept
 
Matrix operator^ (const Matrix &m, const Vector &a) noexcept
 
Matrix operator^ (const Vector &a, const Matrix &m) noexcept
 
Matrix rotate (const Matrix &m, const Vector &axis) noexcept
 
Vector rotationAngles (const Matrix &m) noexcept
 
Vector scale (const Matrix &m) noexcept
 
Matrix transpose (const Matrix &m) noexcept
 

Detailed Description

3x3 column-major matrix, float32

Constructor & Destructor Documentation

◆ Matrix()

VRay::Matrix::Matrix ( const Vector a,
const Vector b,
const Vector c 
)
inlinenoexcept

Constructor from the three columns of the matrix.

Parameters
aThe first column.
bThe second column.
cThe third column.

Member Function Documentation

◆ makeDiagonal()

void VRay::Matrix::makeDiagonal ( const Vector a)
inlinenoexcept

Make the matrix a diagonal matrix with the given elements along the diagonal.

Parameters
aA vector holding the diagonal values. All other elements are initialized to zeroes.

◆ makeInverse()

bool VRay::Matrix::makeInverse ( void  )
inlinenoexcept

Make the matrix to be the inverse of its current value. Checks if the matrix determinant is zero and in that case, zeroes out the matrix.

Returns
zero if the determinant is zero, and non-zero otherwise.

◆ operator+=()

void VRay::Matrix::operator+= ( const Matrix m)
inlinenoexcept

Add another matrix to this one.

Parameters
mThe matrix to add.

◆ operator-=()

void VRay::Matrix::operator-= ( const Matrix m)
inlinenoexcept

Subtract another matrix from this one.

Parameters
mThe matrix to subtract.

◆ set() [1/2]

void VRay::Matrix::set ( const Matrix other)
inlinenoexcept

Set the matrix from another matrix.

Parameters
otherThe other matrix.

◆ set() [2/2]

void VRay::Matrix::set ( const Vector a,
const Vector b,
const Vector c 
)
inlinenoexcept

Copy-constructor from another matrix.

Parameters
otherThe other matrix. Set the columns of the matrix.
aThe first column.
bThe second column.
cThe third column.

◆ setCol()

void VRay::Matrix::setCol ( const int  i,
const Vector a 
)
inlinenoexcept

Set the i-th column of the matrix.

Parameters
iThe index of the column to set (i=0,1,2).
aThe value for the column.

◆ setRow()

void VRay::Matrix::setRow ( const int  i,
const Vector a 
)
inlinenoexcept

Set the i-th row of the matrix.

Parameters
iThe index of the row to set (i=0,1,2).
aThe value of the row.

Friends And Related Function Documentation

◆ inverse()

Matrix inverse ( const Matrix m)
related

Compute the inverse of a matrix.

◆ makeRotationMatrixX()

Matrix makeRotationMatrixX ( float  xrot)
related

Creates a new matrix representing a linear transformation - rotation around the X axis

Parameters
xrotAngle in radians

◆ makeRotationMatrixY()

Matrix makeRotationMatrixY ( float  yrot)
related

Creates a new matrix representing a linear transformation - rotation around the Y axis

Parameters
yrotAngle in radians

◆ makeRotationMatrixZ()

Matrix makeRotationMatrixZ ( float  zrot)
related

Creates a new matrix representing a linear transformation - rotation around the Z axis

Parameters
zrotAngle in radians

◆ normalize()

Matrix normalize ( const Matrix m)
related

Make a matrix orthonormal

◆ noScale()

Matrix noScale ( const Matrix m)
related

Remove scaling from a matrix (make all column unit vectors)

◆ operator!=()

bool operator!= ( const Matrix a,
const Matrix b 
)
related

Checks two matrices for inequality.

◆ operator*() [1/5]

Matrix operator* ( const Matrix a,
const Matrix b 
)
related

Multiply two matrices, so that if p is a Vector, (a*b)*p == a*(b*p).

◆ operator*() [2/5]

Vector operator* ( const Matrix m,
const Vector a 
)
related

Multiply a matrix by a vector. Note that this is different from multiplying the same vector by the same matrix.

◆ operator*() [3/5]

Matrix operator* ( const Matrix m,
float  x 
)
related

Multiply a matrix by a number.

◆ operator*() [4/5]

Vector operator* ( const Vector a,
const Matrix m 
)
related

Multiply a vector by a matrix. Note that this is different from multiplying the matrix by the same vector.

◆ operator*() [5/5]

Matrix operator* ( float  x,
const Matrix m 
)
related

Multiply a number by a matrix. This is the same as multiplying the matrix by the number.

◆ operator+()

Matrix operator+ ( const Matrix a,
const Matrix b 
)
related

Add two matrices, so that if p is a Vector, (a+b)*p == (a*p)+(b*p).

◆ operator-() [1/2]

Matrix operator- ( const Matrix a)
related

Invert the signs of all elements in a matrix.

◆ operator-() [2/2]

Matrix operator- ( const Matrix a,
const Matrix b 
)
related

Subtract two matrices, so that if p is a Vector, (a-b)*p == (a*p)-(b*p).

◆ operator/() [1/2]

Matrix operator/ ( const Matrix m,
float  x 
)
related

Divide all elements of the matrix by a given number. Does not check if the number is zero.

◆ operator/() [2/2]

float operator/ ( float  x,
const Matrix m 
)
related

Divide a number by the determinant of a matrix. Does not check if the determinant is zero.

◆ operator==()

bool operator== ( const Matrix a,
const Matrix b 
)
related

Checks two matrices for exact equality. NOTE: You may want to perform your own approximate comparison, element by element

◆ operator^() [1/2]

Matrix operator^ ( const Matrix m,
const Vector a 
)
related

Cross product of a matrix and a vector.

◆ operator^() [2/2]

Matrix operator^ ( const Vector a,
const Matrix m 
)
related

Cross product of a vector and a matrix.

◆ rotate()

Matrix rotate ( const Matrix m,
const Vector axis 
)
related

Applies a rotation along the given axis. The length of the axis is the tangent of the angle of rotation.

◆ rotationAngles()

Vector rotationAngles ( const Matrix m)
related

Gets the Euler angles that are used to form the rotational part of the matrix

◆ scale()

Vector scale ( const Matrix m)
related

Gets the scaling vector from the matrix


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