Table of Contents

Struct Matrix4

Namespace
CADability
Assembly
CADability.dll

Homogenuos matrix for 3 dimensions, i.e. 4x4 matrix. Mainly used for perspective views.

public struct Matrix4 : ISerializable
Implements
Inherited Members

Constructors

Matrix4(ModOp)

Creates a Matrix4 from an affine modification: the 3*4 coefficients of Matrix completed by the row (0,0,0,1), as ToMatrix() returns them.

public Matrix4(ModOp m)

Parameters

m ModOp

the modification

Matrix4(Matrix<double>)

Creates a Matrix4 as a copy of the given 4*4 matrix. Null yields the identity matrix. Throws an ApplicationException when the matrix does not have 4 rows and 4 columns.

public Matrix4(Matrix<double> hm)

Parameters

hm Matrix<double>

the 4*4 matrix to copy, or null for the identity

Matrix4(double[,])

Creates a Matrix4 from an array of coefficients, which must be 4*4 ([row, column]).

public Matrix4(double[,] m)

Parameters

m double[,]

the coefficients

Fields

hm

The 4*4 homogeneous matrix (MathNet dense matrix). It is null for a default constructed Matrix4, which counts as invalid (see IsValid); multiplying a point or vector with an invalid Matrix4 returns it unchanged. Exposed for direct access, the usual way is to use the operators and Matrix.

public Matrix<double> hm

Field Value

Matrix<double>

Properties

Determinant

The determinant of the 4*4 matrix. It is zero when the matrix is singular and cannot be inverted.

public double Determinant { get; }

Property Value

double

IsValid

True, if this Matrix4 holds a matrix. A default constructed Matrix4 holds none and is invalid.

public bool IsValid { get; }

Property Value

bool

Matrix

The underlying 4*4 matrix as a MathNet dense matrix, e.g. to combine it with other matrices.

public Matrix Matrix { get; }

Property Value

Matrix

Methods

GetInverse()

Returns the inverse of this matrix, e.g. to transform screen coordinates back into the model (see Projection). The matrix must be valid and regular (Determinant not zero).

public Matrix4 GetInverse()

Returns

Matrix4

the inverse matrix

Operators

explicit operator double[,](Matrix4)

Returns the coefficients of the matrix as a 4*4 array ([row, column]).

public static explicit operator double[,](Matrix4 m)

Parameters

m Matrix4

the matrix

Returns

double[,]

the coefficients

operator *(Matrix4, GeoPoint)

Modifies the given point by this modification.

public static GeoPoint operator *(Matrix4 m, GeoPoint p)

Parameters

m Matrix4

modification

p GeoPoint

point

Returns

GeoPoint

modified point

operator *(Matrix4, GeoVector)

Transforms the given vector by this matrix: the translation (fourth column) is ignored, the perspective division by the resulting homogeneous coordinate is applied. An invalid matrix returns the vector unchanged.

public static GeoVector operator *(Matrix4 m, GeoVector v)

Parameters

m Matrix4

the matrix

v GeoVector

the vector

Returns

GeoVector

the transformed vector

operator *(Matrix4, Matrix4)

Combines two matrices into one by the ordinary matrix product: the result applies r first and l afterwards. Both matrices must be valid.

public static Matrix4 operator *(Matrix4 l, Matrix4 r)

Parameters

l Matrix4

the left factor, applied second

r Matrix4

the right factor, applied first

Returns

Matrix4

the product