editor › Globals › MatrixUtils
Class: MatrixUtils
This class helps creating different transformation matrices. Matrices are combined in the order that we like to think about transformations. I.e. calling makeScale and then makeTranslation will lead to a transformation matrix that first scales and then translates, whereas the mathematically correct order would be translationMatrix * scaleMatrix.
Hierarchy
- MatrixUtils
Index
Properties
Methods
- createMirrorTransform
- decompose
- getPositionalRotationFrom2DMatrix
- makeAxisScale
- makeIdentityMatrix
- makeMirror
- makeRotationAxis
- makeRotationFromQuaternion
- makeRotationFromVectorsAroundNormal
- makeScale
- makeSkew
- makeTaperFunction
- makeTransformationForPositionAndNormal
- makeTranslation
- makeUniformScale
Properties
Static Private helperMatrix
▪ helperMatrix: Matrix4‹› = new Matrix4()
Defined in src/util/MatrixUtils.ts:10
Static Private helperVector
▪ helperVector: Vector3‹› = new Vector3()
Defined in src/util/MatrixUtils.ts:11
Methods
Static createMirrorTransform
▸ createMirrorTransform(mirrorPlane: Plane): Matrix4
Defined in src/util/MatrixUtils.ts:212
Calculates the householder transformation and shifts the transform in the origin, for more see: https://en.wikipedia.org/wiki/Householder_transformation
Transforms in the mirror plane coordinate system.
Parameters:
| Name | Type | Description |
|---|---|---|
mirrorPlane |
Plane | plane to mirror the assembly points |
Returns: Matrix4
the transformation matrix
Static decompose
▸ decompose(matrix: Matrix4): object
Defined in src/util/MatrixUtils.ts:140
Parameters:
| Name | Type |
|---|---|
matrix |
Matrix4 |
Returns: object
-
rotation: Quaternion‹›
-
scale: Vector3‹›
-
translation: Vector3‹›
Static getPositionalRotationFrom2DMatrix
▸ getPositionalRotationFrom2DMatrix(transformationMatrix: Matrix4): object
Defined in src/util/MatrixUtils.ts:254
Converts a matrix to 2D position and rotation.
Parameters:
| Name | Type | Description |
|---|---|---|
transformationMatrix |
Matrix4 | The matrix to be converted. |
Returns: object
2D translation vector, angle in degrees.
-
rotationAngle: number
-
translation2D: Vector2
Static makeAxisScale
▸ makeAxisScale(scale: number, axis: "x" | "y" | "z", secondAxis: "x" | "y" | "z" | null, matrix: Matrix4‹›, scalePoint: Vector3 | null): Matrix4‹›
Defined in src/util/MatrixUtils.ts:72
Parameters:
| Name | Type | Default |
|---|---|---|
scale |
number | - |
axis |
"x" | "y" | "z" | - |
secondAxis |
"x" | "y" | "z" | null | null |
matrix |
Matrix4‹› | new Matrix4() |
scalePoint |
Vector3 | null | null |
Returns: Matrix4‹›
Static makeIdentityMatrix
▸ makeIdentityMatrix(): Matrix4
Defined in src/util/MatrixUtils.ts:244
Returns: Matrix4
Static makeMirror
▸ makeMirror(axis: "x" | "y" | "z", matrix: Matrix4‹›, scalePoint: Vector3 | null): Matrix4‹›
Defined in src/util/MatrixUtils.ts:88
Parameters:
| Name | Type | Default |
|---|---|---|
axis |
"x" | "y" | "z" | - |
matrix |
Matrix4‹› | new Matrix4() |
scalePoint |
Vector3 | null | null |
Returns: Matrix4‹›
Static makeRotationAxis
▸ makeRotationAxis(axis: Vector3, angle: number, matrix: Matrix4‹›): Matrix4‹›
Defined in src/util/MatrixUtils.ts:117
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
axis |
Vector3 | - | Axis around which the rotation will be applied |
angle |
number | - | Angle in radians |
matrix |
Matrix4‹› | new Matrix4() | (optional) Matrix to apply the rotation to. |
Returns: Matrix4‹›
Static makeRotationFromQuaternion
▸ makeRotationFromQuaternion(quaternion: ReadonlyQuaternion, matrix: Matrix4‹›): Matrix4
Defined in src/util/MatrixUtils.ts:106
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
quaternion |
ReadonlyQuaternion | - | Rotation quaternion |
matrix |
Matrix4‹› | new Matrix4() | (optional) Matrix to apply the rotation to. |
Returns: Matrix4
Static makeRotationFromVectorsAroundNormal
▸ makeRotationFromVectorsAroundNormal(source: Vector3, target: Vector3, normal: Vector3, matrix: Matrix4‹›): Matrix4‹›
Defined in src/util/MatrixUtils.ts:19
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
source |
Vector3 | - | Vector to rotate from |
target |
Vector3 | - | Vector to rotate to |
normal |
Vector3 | - | Normal around which to rotate |
matrix |
Matrix4‹› | new Matrix4() | (optional) Matrix to apply the rotation to. |
Returns: Matrix4‹›
Static makeScale
▸ makeScale(scale: ReadonlyVector3, matrix: Matrix4‹›, scalePoint?: ReadonlyVector3 | null): Matrix4‹›
Defined in src/util/MatrixUtils.ts:128
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
scale |
ReadonlyVector3 | - | Scale factor for the three axes |
matrix |
Matrix4‹› | new Matrix4() | (optional) Matrix to apply the rotation to. |
scalePoint? |
ReadonlyVector3 | null | - | (optional) Point around which to scale. |
Returns: Matrix4‹›
Static makeSkew
▸ makeSkew(angle: number, normalAxis: "x" | "y" | "z", skewAxis: "x" | "y" | "z", secondSkewAxis: "x" | "y" | "z" | null, matrix: Matrix4‹›): Matrix4‹›
Defined in src/util/MatrixUtils.ts:148
Parameters:
| Name | Type | Default |
|---|---|---|
angle |
number | - |
normalAxis |
"x" | "y" | "z" | - |
skewAxis |
"x" | "y" | "z" | - |
secondSkewAxis |
"x" | "y" | "z" | null | null |
matrix |
Matrix4‹› | new Matrix4() |
Returns: Matrix4‹›
Static makeTaperFunction
▸ makeTaperFunction(taperStart: number, taperScale: number, direction: 1 | -1, normalAxis: "x" | "y" | "z", minNormalAxisValue: number, maxNormalAxisValue: number, taperAxis: "x" | "y" | "z", secondTaperAxis: "x" | "y" | "z" | null): function
Defined in src/util/MatrixUtils.ts:175
Tapering is a non-affine transformation, so it needs a different matrix for every point
Parameters:
| Name | Type | Default |
|---|---|---|
taperStart |
number | - |
taperScale |
number | - |
direction |
1 | -1 | - |
normalAxis |
"x" | "y" | "z" | - |
minNormalAxisValue |
number | - |
maxNormalAxisValue |
number | - |
taperAxis |
"x" | "y" | "z" | - |
secondTaperAxis |
"x" | "y" | "z" | null | null |
Returns: function
Function that returns a matrix for a given point
▸ (pos: Vector3): Matrix4
Parameters:
| Name | Type |
|---|---|
pos |
Vector3 |
Static makeTransformationForPositionAndNormal
▸ makeTransformationForPositionAndNormal(currentPosition: Vector3, currentNormal: Vector3, targetPosition: Vector3, targetNormal: Vector3, mirror: boolean): Matrix4
Defined in src/util/MatrixUtils.ts:32
Constructs a matrix transforming current position and normal to the target
Parameters:
| Name | Type |
|---|---|
currentPosition |
Vector3 |
currentNormal |
Vector3 |
targetPosition |
Vector3 |
targetNormal |
Vector3 |
mirror |
boolean |
Returns: Matrix4
Static makeTranslation
▸ makeTranslation(translation: ReadonlyVector3, matrix: Matrix4‹›): Matrix4‹›
Defined in src/util/MatrixUtils.ts:96
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
translation |
ReadonlyVector3 | - | Translation vector |
matrix |
Matrix4‹› | new Matrix4() | (optional) Matrix to apply the translation to. |
Returns: Matrix4‹›
Static makeUniformScale
▸ makeUniformScale(scale: number, matrix: Matrix4‹›, scalePoint?: Vector3 | null): Matrix4‹›
Defined in src/util/MatrixUtils.ts:67
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
scale |
number | - | Scale factor to apply to all axes |
matrix |
Matrix4‹› | new Matrix4() | (optional) Matrix to apply the rotation to. |
scalePoint? |
Vector3 | null | - | Point around which to scale, optional. |
Returns: Matrix4‹›