Show / Hide Table of Contents

    Class Matrix

    The Matrix class represents a transformation matrix.

    Inheritance
    System.Object
    Matrix
    Inherited Members
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    Namespace: DesignData.SDS2.Primitives
    Assembly: DesignData.SDS2.Primitives.dll
    Syntax
    public sealed class Matrix
    Remarks

    A Matrix has 4x3 floating point elements, and many routines exhibit undefined behavior if the elements of the matrix cannot be composed into a combination of rotations and translations.

    Constructors

    Matrix()

    Create an identity matrix.

    Declaration
    public Matrix()

    Matrix(Matrix)

    Create a matrix equal to the given matrix

    Declaration
    public Matrix(Matrix arg0)
    Parameters
    Type Name Description
    Matrix arg0

    Properties

    Origin

    Get the coordinate system origin.

    Declaration
    public Point3D Origin { get; }
    Property Value
    Type Description
    Point3D

    XAxis

    Get the coordinate system X axis.

    Declaration
    public Vector3D XAxis { get; }
    Property Value
    Type Description
    Vector3D

    YAxis

    Get the coordinate system Y axis.

    Declaration
    public Vector3D YAxis { get; }
    Property Value
    Type Description
    Vector3D

    ZAxis

    Get the coordinate system Z axis.

    Declaration
    public Vector3D ZAxis { get; }
    Property Value
    Type Description
    Vector3D

    Methods

    BetweenSystems(Matrix, Matrix)

    Create a transformation matrix from the first coordinate system to the second coordinate system

    Declaration
    public static Matrix BetweenSystems(Matrix from, Matrix to)
    Parameters
    Type Name Description
    Matrix from

    The "from" coordinate system

    Matrix to

    The "to" coordinate system

    Returns
    Type Description
    Matrix

    BinEquals(Matrix, Double)

    Returns BinEquals() on each sub component of the matrix

    Declaration
    public bool BinEquals(Matrix other, double binSize)
    Parameters
    Type Name Description
    Matrix other

    The other matrix

    System.Double binSize

    The size of a bin.

    Returns
    Type Description
    System.Boolean
    Remarks

    Unlike EpsilonEquals, BinEquals maintains the transitive rule of equality.

    EpsilonEquals(Matrix, Double)

    Returns EpsilonEquals() on each sub component of the matrix

    Declaration
    public bool EpsilonEquals(Matrix other, double distanceSquared)
    Parameters
    Type Name Description
    Matrix other

    The other matrix

    System.Double distanceSquared

    The square of the smallest distance value that should be considered different

    Returns
    Type Description
    System.Boolean
    Remarks

    Note that EpsilonEquals can violate the transitivity rule of equality comparison, because there are many groups of matrices (p, q, r) where p.EpsilonEquals(q) and p.EpsilonEquals(r) but not q.EpsilonEquals(r).

    Equals(Object)

    Checks if each element of the matrix are equal using Equals on each component. Note that this is an "exact" comparison method, and only appropriate in special circumstances.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj

    The matrix to compare to

    Returns
    Type Description
    System.Boolean
    Overrides
    System.Object.Equals(System.Object)

    Finalize()

    Declaration
    protected void Finalize()

    GetHashCode()

    Returns the hash code for this instance. True for instances which are Equals(), otherwise False with high probability. Specific hash values are implementation-dependent.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32
    Overrides
    System.Object.GetHashCode()

    Inverse()

    Return the inverse of this matrix

    Declaration
    public Matrix Inverse()
    Returns
    Type Description
    Matrix

    MirrorZ()

    Create a Matrix mirrored about the XY plane.

    Declaration
    public static Matrix MirrorZ()
    Returns
    Type Description
    Matrix

    Rotation(Double, Vector3D)

    Create a rotation matrix

    Declaration
    public static Matrix Rotation(double angle, Vector3D axis)
    Parameters
    Type Name Description
    System.Double angle

    Counterclockwise rotation in radians

    Vector3D axis

    Axis of rotation

    Returns
    Type Description
    Matrix

    ToCoordinateSystemXY(Point3D, Vector3D, Vector3D)

    Create a coordinate system from X axis, Y axis, and origin location.

    Declaration
    public static Matrix ToCoordinateSystemXY(Point3D origin, Vector3D xAxis, Vector3D yAxis)
    Parameters
    Type Name Description
    Point3D origin

    The origin for the coordinate system

    Vector3D xAxis

    The X axis for the coordinate system, a unit vector

    Vector3D yAxis

    The Y axis for the coordinate system, a unit vector perpendicular to XAxis

    Returns
    Type Description
    Matrix
    Remarks

    Note that the X and Y axes must be perpendicular unit vectors to within about 1 part in 1e-7

    Exceptions
    Type Condition
    InvalidValueException

    If basis vectors are not normalized or perpendicular.

    ToString()

    Formats the point into a string. Note that because the values are rounded for display, parsing them to retrieve the X, Y, and Z values will not necessarily yield the same point.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String
    Overrides
    System.Object.ToString()

    Translation(Point3D)

    Create a translation matrix

    Declaration
    public static Matrix Translation(Point3D origin)
    Parameters
    Type Name Description
    Point3D origin

    The translation applied by the new matrix

    Returns
    Type Description
    Matrix

    XRotation(Double)

    Create a rotation matrix around the X axis

    Declaration
    public static Matrix XRotation(double angle)
    Parameters
    Type Name Description
    System.Double angle

    Counterclockwise rotation in radians

    Returns
    Type Description
    Matrix

    YRotation(Double)

    Create a rotation matrix around the Y axis

    Declaration
    public static Matrix YRotation(double angle)
    Parameters
    Type Name Description
    System.Double angle

    Counterclockwise rotation in radians

    Returns
    Type Description
    Matrix

    ZRotation(Double)

    Create a rotation matrix around the Z axis

    Declaration
    public static Matrix ZRotation(double angle)
    Parameters
    Type Name Description
    System.Double angle

    Counterclockwise rotation in radians

    Returns
    Type Description
    Matrix

    Operators

    Equality(Matrix, Matrix)

    Checks if each element of the matrices are equal using == on each component. Note that this is an "exact" comparison method, and only appropriate in special circumstances.

    Declaration
    public static bool operator ==(Matrix a, Matrix b)
    Parameters
    Type Name Description
    Matrix a

    The matrix to compare

    Matrix b

    The matrix to compare to

    Returns
    Type Description
    System.Boolean

    Inequality(Matrix, Matrix)

    Checks if any element of the matrices are unequal using != on each component. Note that this is an "exact" comparison method, and only appropriate in special circumstances.

    Declaration
    public static bool operator !=(Matrix a, Matrix b)
    Parameters
    Type Name Description
    Matrix a

    The matrix to compare

    Matrix b

    The matrix to compare to

    Returns
    Type Description
    System.Boolean

    Multiply(Matrix, Matrix)

    Return a new matrix which composes the two matrices

    Declaration
    public static Matrix operator *(Matrix arg0, Matrix arg1)
    Parameters
    Type Name Description
    Matrix arg0
    Matrix arg1
    Returns
    Type Description
    Matrix

    Multiply(Matrix, Point3D)

    Return the point transformed by the matrix

    Declaration
    public static Point3D operator *(Matrix arg0, Point3D arg1)
    Parameters
    Type Name Description
    Matrix arg0
    Point3D arg1
    Returns
    Type Description
    Point3D

    Multiply(Matrix, Vector3D)

    Return the vector transformed by the matrix

    Declaration
    public static Vector3D operator *(Matrix arg0, Vector3D arg1)
    Parameters
    Type Name Description
    Matrix arg0
    Vector3D arg1
    Returns
    Type Description
    Vector3D
    Back to top