SilverScreen Solid Modeler

MATRIX

MATRIX

Previous topic Next topic  

MATRIX

Previous topic Next topic JavaScript is required for the print function  

SilverSharpAPI

 

SilverSharp.MATRIX

 

Structure

The SilverSharp.MATRIX object represents a 3D homogeneous transformation matrix

 

C# Code

 

 class MATRIX

    {

    MATRIX();

    MATRIX(MATRIX m);

 

    string   ToString();

 

    double   MATRIX[int row, int col];

 

    static   MATRIX operator * (MATRIX lhs, MATRIX rhs);

    static   SS_XYZ operator * (SS_XYZ lhs, MATRIX rhs);

 

    MATRIX   operator *= (MATRIX rhs);

 

    bool     Invert();

    MATRIX   CopyAndInvert();

 

    void     Transform(ref SS_XYZ[] pts);

    SS_XYZ[] CopyAndTransform(SS_XYZ[] pts);

 

    void     Clear();

    void     Transpose();

 

    void     Translate(double dx, double dy, double dz);

    void     Translate(SS_XYZ pt);

 

    void     Scale(double xScale, double yScale, double zScale);

    void     ScaleX(double xScale);

    void     ScaleY(double yScale);

    void     ScaleZ(double zScale);

         

    void     RotateX(double degrees);

    void     RotateY(double degrees);

    void     RotateZ(double degrees);        

    };

 

 

 

Operator overrides

Operator

Description

MATRIX operator *

Multiplies two transformation matrices together and returns the result

MATRIX operator *=

Post-multiply the MATRIX object by another, and store the result within

SS_XYZ operator *

Transforms a 3D point via a matrix and return the result

 

The following code shows how to make use of the operator overrides. The SilverScreen API contains functions such as tm_multiply and tm_transform to do the same work. The code below is illustrative and does not perform useful work:

 

C# Code

 

 using SilverSharp;

 

 . . .

 

 MATRIX mx1 = new MATRIX();

 MATRIX mx2 = new MATRIX();

 

 mx1.Scale(0.5, 0.5, 1.0); // The first matrix will scale by 1/2

 mx2.Scale(2.0, 2.0, 1.0); // The second matrix will multiply by 2

 

 MATRIX mx3 = mx1 * mx2;

 MATRIX mx4 = new MATRIX(mx1); // Copy mx1

 

 mx4 *= mx2; // mx4 = mx4 * mx2

 

 SS_XYZ pt  = new SS_XYZ(5.0, 5.0, -5.0);

 

 SS_XYZ pt2 = pt * mx1; // Return 'pt' transformed by 'mx1'

 

 

 

Properties

Property

Description

MATRIX[int row, int col];

A read + write indexer to access a SilverSharp.MATRIX as if it were a 2D array of doubles

 

The following code shows how to make use of the indexer to write cells of a SilverSharp.MATRIX object:

 

C# Code

 

 using SilverSharp;

 

 . . .

 

 MATRIX mx1 = new MATRIX();

 

 mx1[0,0] = 2.0;

 mx1[1,1] = 2.0;

 

 

 

Methods

Member

Description

Clear

Clears the matrix object to an identity matrix

CopyAndInvert

Makes a copy of the MATRIX object, then inverts it.

CopyAndTransform

Makes a copy of a 3D point array, transforms the copied points, and returns the resulting array.

Invert

Inverts the matrix in-place

MATRIX

Constructor(s) to initialize object

RotateX

Post-multiplies a matrix that rotates about the x coordinate axis

RotateY

Post-multiplies a matrix that rotates about the y coordinate axis

RotateZ

Post-multiplies a matrix that rotates about the z coordinate axis

Scale

Post-multiplies a matrix that scales along all 3 coordinate axes

ScaleX

Post-multiplies a matrix that scales along the x coordinate axis

ScaleY

Post-multiplies a matrix that scales along the y coordinate axis

ScaleZ

Post-multiplies a matrix that scales along the z coordinate axis

ToString

Formats the MATRIX object as a string

Transform

Transforms a 3D point array in-place by the matrix object.

Translate

Post-multiplies a matrix that translates a 3D point to the origin

Transpose

Transposes the matrix object in-place

 

 

See Also

tm_multiply, tm_transform, tm_scale_x, tm_rotate_x, tm_inverse