An implementation of a matrix that represents an affine transformation and works with Point.
Remarks
The matrix is interpreted row-major. The rows are defined as follows: [ m11 m12 dx ], [ m21 m22 dy ], ([ 0 0 1 ] implicitly).
When transforming a vector v using this matrix, the multiplication is done in this order: v' = M v.
PREPENDing a matrix T to this instance results in the operation M′ = M T. In concept, this means that T is applied before M when applying M' to a vector. APPENDing T to M results in M′ = T M.
Type Details
- yFiles module
- view
Constructors
Creates a matrix using the provided matrix entries.
Parameters
A map of options to pass to the method.
- m11 - number
- The value in the first row and first column of the matrix, representing the x scaling factor.
- m12 - number
- The value in the first row and second column of the matrix, representing the x shear factor.
- m21 - number
- The value in the second row and first column of the matrix, representing the y shear factor.
- m22 - number
- The value in the second row and second column of the matrix, representing the y scaling factor.
- dx - number
- The value in the first row and third column of the matrix, representing the x translation (offset).
- dy - number
- The value in the second row and third column of the matrix, representing the y translation (offset).
Properties
Methods
Transforms the four corner points of the given rectangle and returns the bounds of the transformed points.
Parameters
A map of options to pass to the method.
- rectangle - Rect
- The rectangle instance.
Returns
See Also
Create a clone of this object.
Multiplies this matrix instance by the given instance using the given order.
Parameters
A map of options to pass to the method.
- matrix - Matrix
- The matrix to multiply with this one.
- order - MatrixOrder
- The order of the multiplication. PREPEND if not specified.
Prepends or appends a rotation operation to this matrix around the specified rotation center.
Parameters
A map of options to pass to the method.
- theta - number
- The rotation angle in radians
- center - Point
- The center of the rotation.
- order - MatrixOrder
- Whether to append or prepend the rotation matrix.
Prepends or appends a rotation operation to this matrix around the origin.
Parameters
A map of options to pass to the method.
- theta - number
- The rotation angle in radians
- order - MatrixOrder
- Whether to append or prepend the rotation matrix.
Appends or prepends a scale operation to this instance.
Parameters
A map of options to pass to the method.
- x - number
- The x-axis scaling factor.
- y - number
- The y-axis scaling factor.
- order - MatrixOrder
- The order in which the scaling should be applied. The default is PREPEND.
Sets all elements of this instance.
Parameters
A map of options to pass to the method.
- m0 - number
- The value for M11.
- m1 - number
- The value for M12.
- m2 - number
- The value for M21.
- m3 - number
- The value for M22.
- dx - number
- Translation in x-direction.
- dy - number
- Translation in y-direction.
Converts the Matrix object to a CSS transform.
Remarks
Returns
- ↪string
- The transform string
Converts the Matrix object to an SVG transform string.
Remarks
Returns
- ↪string
- The transform string
Transforms the given point in place.
Parameters
A map of options to pass to the method.
- point - IMutablePoint
- The point to transform and return.
Returns
- ↪IMutablePoint
point
Appends or Prepends a translation to this instance.
Parameters
A map of options to pass to the method.
- delta - Point
- The translation delta.
- order - MatrixOrder
- The order in which the translation should be applied. The default is PREPEND.
Constants
Gets an unmodifiable identity matrix.
Gets an unmodifiable projection matrix that makes the graph look isometric.
See Also
Static Methods
Creates a transformation matrix that can be used to transform points that are in the local coordinate system of the oriented rectangle if the top-left corner is the origin.
Parameters
A map of options to pass to the method.
- rectangle - IOrientedRectangle
- The oriented rectangle to use for defining the coordinate space.
Returns
- ↪Matrix
- A matrix that can be used to transform from oriented rectangle coordinates to world coordinates.
Implements the vector transformation by calling transform.
Parameters
A map of options to pass to the method.
Returns
- ↪Point
- The result of the transformation.
Examples
const v = new Point(2, 5)
// Make the vector three times as long
const longer = v.multiply(3)
console.log(longer) // (6, 15)
// Make the vector half as long
const shorter = v.multiply(0.5)
console.log(shorter) // (1, 2.5)
// Translate and scale the vector via a matrix
const matrix = new Matrix()
matrix.scale(2, 1.5)
matrix.translate(new Point(5, -3))
// ... or the transform method on Matrix
const p = new Point(7, 2)
const transformed = matrix.transform(p)
console.log(transformed) // (24, -1.5)