3ds Max C++ API Reference
Matrix2 Class Reference

#include <matrix2.h>

+ Inheritance diagram for Matrix2:

Public Member Functions

 Matrix2 ()=default
 
 Matrix2 (const Matrix2 &)=default
 
 Matrix2 (Matrix2 &&)=default
 
Matrix2operator= (const Matrix2 &)=default
 
Matrix2operator= (Matrix2 &&)=default
 
 Matrix2 (BOOL init)
 
 Matrix2 (float(*fp)[2])
 
Matrix2operator-= (const Matrix2 &M)
 
Matrix2operator+= (const Matrix2 &M)
 
Matrix2operator*= (const Matrix2 &M)
 
 operator float * ()
 
void IdentityMatrix ()
 
void Zero ()
 
Point2 GetRow (int i) const
 
void SetRow (int i, Point2 p)
 
Point3 GetColumn (int i)
 
void SetColumn (int i, Point3 col)
 
Point2 GetColumn2 (int i)
 
void SetTrans (const Point2 p)
 
void SetTrans (int i, float v)
 
Point2 GetTrans ()
 
void Translate (const Point2 &p)
 
void Rotate (float angle)
 
void Scale (const Point2 &s, BOOL trans=FALSE)
 
void PreTranslate (const Point2 &p)
 
void PreRotate (float angle)
 
void PreScale (const Point2 &s)
 
void SetTranslate (const Point2 &s)
 
void SetRotate (float angle)
 
void Invert ()
 
Matrix2 operator* (const Matrix2 &B) const
 
Matrix2 operator+ (const Matrix2 &B) const
 
Matrix2 operator- (const Matrix2 &B) const
 
IOResult Save (ISave *isave)
 
IOResult Load (ILoad *iload)
 

Public Attributes

float m [3][2]
 

Static Public Attributes

static const Matrix2 Identity
 

Additional Inherited Members

- Static Public Member Functions inherited from MaxHeapOperators
static UtilExport voidoperator new (size_t size)
 Standard new operator used to allocate objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e)
 Standard new operator used to allocate objects if there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate objects that takes the type of memory, filename and line number where the new was called If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate objects that takes the filename and line number where the new was called If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new (size_t size, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate objects that takes extra flags to specify special operations If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, int block_type, const char *filename, int line)
 New operator used to allocate arrays of objects. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, const char *filename, int line)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport voidoperator new[] (size_t size, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, an exception will be thrown. More...
 
static UtilExport voidoperator new[] (size_t size, const std::nothrow_t &e, unsigned long flags)
 New operator used to allocate arrays of objects If there is insufficient memory, NULL will be returned. More...
 
static UtilExport void operator delete (void *ptr)
 Standard delete operator used to deallocate an object If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an object If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an object that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an object that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete (void *ptr, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an object that takes extra flags to specify special operations If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e)
 Standard delete operator used to deallocate an array of objects If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, int block_type, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the type of memory, filename and line number where the delete was called If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, const char *filename, int line)
 Delete operator used to deallocate an array of objects that takes the filename and line number where the delete was called If the pointer is invalid, nothing will happen. More...
 
static UtilExport void operator delete[] (void *ptr, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport void operator delete[] (void *ptr, const std::nothrow_t &e, unsigned long flags)
 Delete operator used to deallocate an array of objects that takes extra flags to specify special operations If the pointer is invalid, an exception will be thrown. More...
 
static UtilExport voidoperator new (size_t size, void *placement_ptr)
 Placement new operator. More...
 
static UtilExport void operator delete (void *ptr, void *placement_ptr)
 Placement delete operator. More...
 
static UtilExport voidaligned_malloc (size_t size, size_t alignment)
 Allocates memory on a specified alignment boundary. More...
 
static UtilExport voidaligned_realloc (void *ptr, size_t size, size_t alignment)
 Reallocates memory on a specified alignment boundary. More...
 
static UtilExport void aligned_free (void *ptr)
 Frees a block of memory that was allocated with aligned_malloc/aligned_realloc. More...
 

Detailed Description

See also
Class Point2, Class Point3, Class Matrix3.

Description:
This class defines a 3x2 2D transformation matrix. Methods are provided to zero the matrix, set it to the identity matrix, translate, rotate and scale it, and compute its inverse. Operators are available for matrix addition, subtraction and multiplication. All methods of this class are implemented by the system.
Data Members:
float m[3][2];

Constructor & Destructor Documentation

◆ Matrix2() [1/5]

Matrix2 ( )
default
Remarks
Constructor. Initialized to Identity.

◆ Matrix2() [2/5]

Matrix2 ( const Matrix2 )
default

◆ Matrix2() [3/5]

Matrix2 ( Matrix2 &&  )
default

◆ Matrix2() [4/5]

Matrix2 ( BOOL  init)
inline
62  {
63  UNUSED_PARAM(init);
65  } // An option to initialize
#define UNUSED_PARAM(x)
Definition: BuildWarnings.h:18
void IdentityMatrix()

◆ Matrix2() [5/5]

Matrix2 ( float(*)  fp[2])
Remarks
Constructor. The matrix is initialized using fp.

Member Function Documentation

◆ operator=() [1/2]

Matrix2& operator= ( const Matrix2 )
default

◆ operator=() [2/2]

Matrix2& operator= ( Matrix2 &&  )
default

◆ operator-=()

Matrix2& operator-= ( const Matrix2 M)
Remarks
Subtracts a Matrix2 from this Matrix2.

◆ operator+=()

Matrix2& operator+= ( const Matrix2 M)
Remarks
Adds a Matrix2 to this Matrix2.

◆ operator*=()

Matrix2& operator*= ( const Matrix2 M)
Remarks
Matrix multiplication between this Matrix2 and M.

◆ operator float *()

operator float * ( )
inline
Remarks
Returns the address of the Matrix2.
84  {
85  return (&m[0][0]);
86  }
float m[3][2]
Definition: matrix2.h:46

◆ IdentityMatrix()

void IdentityMatrix ( )
Remarks
Sets this Matrix2 to the Identity Matrix.

◆ Zero()

void Zero ( )
Remarks
Set all elements of this Matrix2 to 0.0f

◆ GetRow()

Point2 GetRow ( int  i) const
inline
Remarks
Returns the specified row of this matrix.
Parameters:
int i

Specifies the row to retrieve (0-2).
99  {
100  return (*this)[i];
101  }

◆ SetRow()

void SetRow ( int  i,
Point2  p 
)
inline
Remarks
Sets the specified row of this matrix.
Parameters:
int i

Specifies the row to set (0-2).

Point2 p

The values to set.
109  {
110  (*this)[i] = p;
111  }

◆ GetColumn()

Point3 GetColumn ( int  i)
Remarks
Returns the specified column of this matrix.
Parameters:
int i

Specifies the column to retrieve (0 or 1).

◆ SetColumn()

void SetColumn ( int  i,
Point3  col 
)
Remarks
Sets the specified column of this matrix.
Parameters:
int i

Specifies the column to set (0 or 1).

Point3 col

The values to set.

◆ GetColumn2()

Point2 GetColumn2 ( int  i)
Remarks
This method returns a Point2 containing the upper two rows of the specified column.
Parameters:
int i

Specifies the column to get (0 or 1).

◆ SetTrans() [1/2]

void SetTrans ( const Point2  p)
inline
Remarks
Sets the translation row of the matrix to the specified values.
Parameters:
const Point2 p

The values to set.
139  {
140  (*this)[2] = p;
141  }

◆ SetTrans() [2/2]

void SetTrans ( int  i,
float  v 
)
inline
Remarks
Sets the specified element of the translation row of this matrix to the specified value.
Parameters:
int i

Specifies which column to set (0 or 1)

float v

The value to store.
150  {
151  (*this)[2][i] = v;
152  }

◆ GetTrans()

Point2 GetTrans ( )
inline
Remarks
Returns the translation row of this matrix.
155  {
156  return (*this)[2];
157  }

◆ Translate()

void Translate ( const Point2 p)
Remarks
Apply an incremental translation to this matrix.
Parameters:
const Point2& p

Specifies the amount to translate the matrix.

◆ Rotate()

void Rotate ( float  angle)
Remarks
Apply an incremental rotation to this matrix using the specified angle.
Parameters:
float angle

Specifies the angle of rotation.

◆ Scale()

void Scale ( const Point2 s,
BOOL  trans = FALSE 
)
Remarks
Apply an incremental scaling to this matrix using the specified scale factors.
Parameters:
const Point2& s

The scale factors.

BOOL trans = FALSE

If set to TRUE, the translation component is scaled. If trans = FALSE the translation component is unaffected. When 3ds Max was originally written there was a bug in the code for this method where the translation portion of the matrix was not being scaled. This meant that when a matrix was scaled the bottom row was not scaled. Thus it would always scale about the local origin of the object, but it would scale the world axes. When this bug was discovered, dependencies existed in the code upon this bug. Thus it could not simply be fixed because it would break the existing code that depended upon it working the incorrect way. To correct this the trans parameter was added. If this is set to TRUE, the translation component will be scaled correctly. The existing plug-ins don't use this parameter, it defaults to FALSE, and the code behaves the old way.

◆ PreTranslate()

void PreTranslate ( const Point2 p)

◆ PreRotate()

void PreRotate ( float  angle)

◆ PreScale()

void PreScale ( const Point2 s)

◆ SetTranslate()

void SetTranslate ( const Point2 s)
Remarks
Initializes the matrix to the identity then sets the translation row to the specified values.
Parameters:
const Point2& s

The values to store.

◆ SetRotate()

void SetRotate ( float  angle)
Remarks
Initializes the matrix to the identity then sets the rotation to the specified value.
Parameters:
float angle

The rotation angle in radians.

◆ Invert()

void Invert ( )
Remarks
This matrix may be used to invert the matrix in place.

◆ operator*()

Matrix2 operator* ( const Matrix2 B) const
Remarks
Perform matrix multiplication.

◆ operator+()

Matrix2 operator+ ( const Matrix2 B) const
Remarks
Perform matrix addition.

◆ operator-()

Matrix2 operator- ( const Matrix2 B) const
Remarks
Perform matrix subtraction.

◆ Save()

IOResult Save ( ISave isave)

◆ Load()

IOResult Load ( ILoad iload)

Member Data Documentation

◆ m

float m[3][2]
Initial value:
= {
{ 1.f, 0.f },
{ 0.f, 1.f },
{ 0.f, 0.f },
}

◆ Identity

const Matrix2 Identity
static