Class BigMatrix

3DS Max Plug-In SDK

Class BigMatrix

See Also: Class Matrix3.

class BigMatrix

Description:

This class is available in release 2.0 and later only.

This class implements an m x n matrix for situations & calculations where the usual 4x3 Matrix3 class is not adequate. BigMatrix implements several useful matrix operations, including matrix multiplication and inversion, but is not guaranteed to be especially efficient. All methods are implemented by the system.

Data Members:

public:

int m, n

The dimensions of the matrix. There are m rows and n columns.

float *val

The elements of the matrix. val[i*n+j] is the value in the i’th row and the j’th column.

Methods:

Prototype:

BigMatrix();

Remarks:

Initializer. Sets m and n to zero, and val to NULL.

Prototype:

BigMatrix(int mm, int nn);

Remarks:

Initializer. Sets the dimensions of the matrix to mm by nn, and allocates space for the contents. The total size of the matrix, mm*nn, cannot exceed 10,000.

Prototype:

BigMatrix(const BigMatrix & from);

Remarks:

Initializer. Sets this BigMatrix equal to from.

Prototype:

~BigMatrix();

Remarks:

Destructor. Frees the internal arrays.

Prototype:

void Clear();

Remarks:

Frees the internal arrays and sets the matrix’s size to 0x0.

Prototype:

int SetSize(int mm, int nn);

Remarks:

Sets the matrix’s size to mm by nn, and allocates space for the contents.

Return Value:

Returns the total size of the matrix (mm * nn) or -1 if there’s an error.

Prototype:

float *operator[](int i) const;

Remarks:

Returns a pointer to the i’th row in the matrix. Thus for a BigMatrix A, A[i][j] is the value in the i’th row and the j’th column.

Prototype:

BigMatrix & operator=(const BigMatrix & from);

Remarks:

Sets this BigMatrix equal to from.

Prototype:

void SetTranspose(BigMatrix & trans) const;

Remarks:

Sets trans to be the transpose of this BigMatrix.

Prototype:

float Invert();

Remarks:

Inverts this matrix. Note that this only works if this matrix is "square", i.e. if m = n. This algorithm is CUBIC in the number of rows, so be careful!

Return Value:

The determinant of the matrix (before inversion) is returned. If the return value is 0, the matrix could not be inverted.

Prototype:

void Identity();

Remarks:

If m and n are equal, this method sets this matrix to the identity. If m and n are not equal, it does nothing.

Prototype:

void Randomize(float scale);

Remarks:

This method is available in release 2.5 or later only.

Creates a random matrix for testing purposes. Reseeds the random number generator with the current system time, for a non-reproducible result. Values of the matrix are set to anything in the range (-scale, scale).

Prototype:

void MNDebugPrint();

Remarks:

This method is available in release 2.5 or later only.

This method prints the contents of the BigMatrix to the IDE debugging window using DebugPrints.