Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes

Unigine::mat2 Class

Header:#include <UnigineMathLib.h>

This class represents a matrix of four (2x2) float components.

mat2 Class

Members


mat2()

Default constructor. Produces an identity matrix.

mat2(const mat2 & m)

Constructor. Initializes the matrix by copying a given source matrix.

Arguments

  • const mat2 & m - Source matrix.

mat2(float v)

Constructor. Initializes the matrix using a given scalar value.
Source code (UnigineScript)
mat2(2.0);
						
/* Creates a matrix						
| 2.0	2.0	|
| 2.0	2.0	|
*/

Arguments

  • float v - Scalar value.

mat2(const mat3 & m)

Constructor. Initializes the matrix using a given mat3 source matrix (3x3). The matrix elements are filled using corresponding elements of the source matrix.

Arguments

  • const mat3 & m - Source matrix (3x3).

mat2(const mat4 & m)

Constructor. Initializes the matrix using a given mat4 source matrix (4x4). The matrix elements are filled using corresponding elements of the source matrix.

Arguments

  • const mat4 & m - Source matrix (4x4).

mat2(const dmat4 & m)

Constructor. Initializes the matrix using a given dmat4 source matrix (3x4). The matrix elements are filled using corresponding elements of the source matrix.

Arguments

  • const dmat4 & m - Source matrix (3x4).

mat2(const float * m)

Constructor. Initializes the matrix using a given pointer to the source matrix.

Arguments

  • const float * m - Pointer to the source matrix.

mat2(const vec2 & col0, const vec2 & col1)

Constructor. Initializes the matrix by given two vec2 vectors.
Output
Resulting matrix: 
    | col0.x   	 col1.x | 
M=  | col0.y     col1.y |

Arguments

  • const vec2 & col0 - Source vector for the first column.
  • const vec2 & col1 - Source vector for the second column.

void set(const float * m)

Sets new matrix values using a pointer to the source matrix.

Arguments

  • const float * m - Pointer to the source matrix.

void set(const mat2 & m)

Sets the matrix equal to the specified source matrix.

Arguments

  • const mat2 & m - Source matrix.

void set(const mat3 & m)

Sets the matrix using a given mat3 source matrix (3x3). Values m00, m01, m10, m11 from the source matrix are used.

Arguments

  • const mat3 & m - Source matrix (3x3).

void set(const mat4 & m)

Sets the matrix using a given mat4 source matrix (4x4). Values m00, m01, m10, m11 from the source matrix are used.

Arguments

  • const mat4 & m - Source matrix (4x4).

void set(const dmat4 & m)

Sets the matrix using a given dmat4 source matrix (3x4). Values m00, m01, m10, m11 from the source matrix are used.

Arguments

  • const dmat4 & m - Source matrix (3x4).

void set(int row, int column, float v)

Sets a new value of the matrix element specified by row and column.

Arguments

  • int row - Row.
  • int column - Column.
  • float v - The value to be set.

float * get()

Returns the pointer to the matrix.

Return value

Pointer to the matrix.

const float * get()

Returns the constant pointer to the matrix.

Return value

Constant pointer to the matrix.

void get(float * m)

Fills the destination matrix, specified by the given pointer, with matrix values.

Arguments

  • float * m - Destination matrix pointer.

float & get(int row, int column)

Returns the reference to the matrix element specified by given row and column.

Arguments

  • int row - Row.
  • int column - Column.

Return value

Matrix element reference.

float get(int row, int column)

Returns the value of the matrix element specified by given row and column.

Arguments

  • int row - Row.
  • int column - Column.

Return value

Matrix element value.

void setColumn(int column, const vec2 & v)

Sets the specified column of the matrix using a given vec2 vector as a source.

Arguments

  • int column - Column.
  • const vec2 & v - Source vector.

vec2 getColumn(int column)

Returns the specified matrix column.

Arguments

  • int column - Column.

Return value

The vec2 vector with column values.

void setIdentity()

Sets the matrix equal to the identity matrix.

void setRotate(float angle)

Fills the rotation matrix using a given angle.
Output
Rotation matrix: 
    | cos(angle)   	-sin(angle) | 
R=  | sin(angle)     cos(angle) |

Arguments

  • float angle - Rotation angle, in degrees.

void setRow(int row, const vec2 & v)

Sets the specified row of the matrix using a given vec2 vector as a source.

Arguments

  • int row - Row.
  • const vec2 & v - Source vector.

vec2 getRow(int row)

Returns the specified matrix row.

Arguments

  • int row - Row.

Return value

The vec2 vector with row values.

void setScale(const vec2 & v)

Fills the scaling matrix using a given vec2 source vector.
Output
Scaling matrix: 
    | v.x   	0.0f | 
S=  | 0.0f      v.y  |

Arguments

  • const vec2 & v - Source vector.

void setZero()

Sets all matrix elements equal to 0.

const float * operator const float *()

Performs type conversion to const float *.

const void * operator const void *()

Performs type conversion to const void *.

float * operator float *()

Performs type conversion to float *.

void * operator void *()

Performs type conversion to void *.

mat2 & operator*=(const mat2 & m)

Performs matrix multiplication.

Arguments

  • const mat2 & m - Matrix.

Return value

Resulting matrix.

mat2 & operator*=(float v)

Performs scalar multiplication.

Arguments

  • float v - Scalar value.

Return value

Resulting matrix.

mat2 & operator+=(const mat2 & m)

Performs matrix addition.

Arguments

  • const mat2 & m - Matrix.

Return value

Resulting matrix.

mat2 operator-()

Performs matrix negation.

Return value

Resulting matrix.

mat2 & operator-=(const mat2 & m)

Performs matrix subtraction.

Arguments

  • const mat2 & m - Matrix.

Return value

Resulting matrix.

mat2 & operator=(const mat2 & m)

Performs matrix assignment. Destination matrix = Source matrix.

Arguments

  • const mat2 & m - Source matrix.

Return value

Result.

float operator[](int i)

Performs array access to the matrix item using a given item index.

Arguments

  • int i - Matrix item index.

Return value

Matrix item.

float & operator[](int i)

Performs array access to the matrix item reference using a given item index.

Arguments

  • int i - Matrix item index.

Return value

Matrix item reference.

__m128 sse()

Returns the values of the matrix elements as a 128-bit variable.
Notice
We do not recommend to use this method unless you have a clear understanding of SSE2.

Return value

128-bit variable.

void sse(const __m128 & v)

Sets the values of the matrix elements using a given 128-bit variable.
Notice
We do not recommend to use this method unless you have a clear understanding of SSE2.

Arguments

  • const __m128 & v - 128-bit variable.

mat2 IDENTITY

Description

Identity matrix.

mat2 ONE

Description

Matrix of ones.

mat2 ZERO

Description

Zero matrix.
Last update: 2017-12-21