70002395 Export methods for matrix oparations in web control

Article 70002395
Type Wish
Product WebJS
Version 1003
Date Added 8/10/2023 12:00:00 AM
Fixed 10.1004.0.7 (8/11/2023 12:00:00 AM)
Submitted by Dariusz Johanik

Summary

Export methods for matrix oparations in web control

Solution

New methods that manipulate matrix oparations exported in version 1004.0.7
matrixtransformEntity(object mat, object entity, vdrawObj vdcanvas)
Transforms the passed entity with a matrix.
vdcanvas : is passed used to run the vdrawObj.UpdateFig method after the transformation

object matrixtransformVector(object matrix, double x, double y, double z, bool normalize)
Transforms the vector using the passed matrix.
and returns a new transformed vector as an array object with 3 elements (x, y, z).
if normalized exist and is true the return verctor is normalized to 1 unit kength

object matrixGetInversion(object matrix)
Gets the invertersion of the passed matrix

matrixInvert(object matrix)
Invert the passed Matrix.

object matrixtransformVertex(object matrix, object vertex)
Tranforms the passed vertex with the passed matrix.
passed vertex is usually an item of polyline VertexList as an array of [x,y,z,bulge]

object matrixtransformVertexes(object matrix, object vertexes)
Transforms all items of the passed collection with passed matrix.

object matrixtransformPts(object matrix, object pts)
Transforms all points objects of the passed collection with passed matrix.

object matrixtransformBOX(object matrix, object box)
Transform the passed box (xmin,ymin,zmin,xmax,ymax,zmax) with passed matrix

object matrixmult(object matrix1, object matrix2)
Multiplies matrix1 x matrix2 and return a new matrix result

object newmatrix()
Returns a new initialized matrix

object matrixclone(object matrix)
Returns a new clone of the passed matrix

matrixInit(object matrix)
Initialize the passed matrix

matrixCopyFrom(object matrix, object from)
Copy the contents of passed from to the passed matrix

matrixmult1(object matrix, object withmatrix)
Multiply passed matrix x withmatrix and set the result to the passed matrix

bool matrixIsUnitMatrix(object matrix)
Check if the passed matrix is initialized

object matrixxdir(object matrix)
Returns the x direction as new [x,y,z] of the passed matrix

object matrixydir(object matrix)
Returns the y direction as new [x,y,z] of the passed matrix

object matrixzdir(object matrix)
Returns the z direction as new [x,y,z] of the passed matrix

object matrixoffset(object matrix)
Returns the offset as new [x,y,z] of the passed matrix

object matrixScales(object matrix)
Returns the scales as new [x,y,z] of the passed matrix

matrixtranslate(object matrix, double dx, double dy, double dz)
Applies an offset to the passed matrix.

matrixscale(object matrix, double xscale, double yscale, double zscale)
Applies x,y,z scales to the passed matrix.

matrixRotateZMatrix(object matrix, double rads)
Applies a rotation in radians around Z direction to the passed matrix.

matrixRotateXMatrix(object matrix, double rads)
Applies a rotation in radians around X direction to the passed matrix.

matrixRotateYMatrix(object matrix, double rads)
Applies a rotation in radians around Y direction to the passed matrix.

matrixShear(object matrix, double Sx, double Sy)
Applies the passed Shear x and Shear y values to passed matrix.

matrixRotateAboutAxis(object matrix, object axis, double rotation)
Applies a rotation in radians around passed axis direction to the passed matrix.

matrixApplyWCS2ECS(object matrix, object zAxis)
Multiplies the passed Matrix with the invertion of the ApplyECS2WCS Matrix.

matrixApplyECS2WCS(object matrix, object zAxis)
Modify the passed matrix in order to be perpedicular to the passed vector.

matrixApplyECS2WCS_2(object matrix, object zAxis, object xAxis)
Modify the passed matrix in order to be perpedicular to the passed zAxis vector and the x direction of the matrix is equal to the passed xAxis vector.


Example:
//create a new 2d mirror matrix around x axis
             var mat = vdgeo.newmatrix();
             vdgeo.matrixscale(mat, 1.0, -1.0, 1.0);
             //transorm all document Model entities
             var doc = vdcanvas.GetDocument();
             for (var i = 0; i < doc.Model.Entities.Items.length; i++) {
                 vdgeo.matrixtransformEntity(mat, vdcanvas.GetEntityItem(doc.Model.Entities.Items[i]), vdcanvas);
             }
             vdcanvas.UpdateLayout(doc.Model); //update layout bounding box
             setTimeout(vdcanvas.redraw); //post a redraw

Send comments on this topic.