Transform Class

A Transform consists of an origin and a Matrix3d. This describes a coordinate frame with this origin, with the columns of the Matrix3d being the local x,y,z axis directions.

  • The math for a Transform T consisting of a Matrix3d M and a Point3d o on a Vector3d p is: Tp = M*p + o. In other words, T is a combination of two operations on p: the action of matrix multiplication, followed by a translation. Origin is a traditional term for o, because T can be interpreted as a change of basis from the global axes centered at the global origin, to a new set of axes specified by matrix M columns centered at o.
  • Beware that for common transformations (e.g. scale about point, rotate around an axis) the fixed point that is used when describing the transform is NOT the origin stored in the transform. Setup methods (e.g createFixedPointAndMatrix, createScaleAboutPoint) take care of determining the appropriate origin coordinates.
  • If T is a translation, no point is fixed by T.
  • If T is the identity, all points are fixed by T.
  • If T is a scale about a point, one point is fixed by T.
  • If T is a rotation about an axis, a line is fixed by T.
  • If T is a projection to the plane, a plane is fixed by T.

Implements

Methods

Name Description
clone(result?: Transform): Transform Copy the contents of this transform into a new Transform (or to the result, if specified).  
cloneRigid(axisOrder: AxisOrderAxisOrder.XYZ): undefined | Transform Return a modified copy of this Transform so that its matrix part is rigid (origin part is untouched).  
computeCachedInverse(useCached: booleantrue): boolean * Compute (if needed) the inverse of the matrix part of the Transform, thereby ensuring inverse  
freeze(): Readonly<Transform> Freeze this instance (and its members) so it is read-only  
getMatrix(): Matrix3d return a (clone of) the matrix part of the Transform, as a Matrix3d  
getOrigin(): Point3d return a (clone of) the origin part of the Transform, as a Point3d  
getTranslation(): Vector3d return a (clone of) the origin part of the Transform, as a Vector3d  
inverse(result?: Transform): undefined | Transform Return a Transform which is the inverse of this Transform.  
isAlmostEqual(other: Readonly<Transform>): boolean Test for near equality with other Transform.  
isAlmostEqualAllowZRotation(other: Transform): boolean Test for near equality with other Transform.  
multiplyComponentXYZ(componentIndex: number, x: number, y: number, z: number0): number Multiply a specific row (component) of the 3x4 instance times (x,y,z,1).  
multiplyComponentXYZW(componentIndex: number, x: number, y: number, z: number, w: number): number Multiply a specific row (component) of the 3x4 instance times (x,y,z,w).  
multiplyInversePoint3d(point: Readonly<WritableXYAndZ>, result?: Point3d): undefined | Point3d Multiply the point by the inverse Transform.  
multiplyInversePoint3dArray(points: Point3d[], result?: Point3d[]): undefined | Point3d[] Multiply each point in the array by the inverse of this Transform.  
multiplyInversePoint3dArrayInPlace(points: Point3d[]): boolean Multiply each point in the array by the inverse of this Transform in place.  
multiplyInversePoint4d(weightedPoint: Point4d, result?: Point4d): undefined | Point4d Multiply the homogenous point by the inverse Transform.  
multiplyInverseXYZ(x: number, y: number, z: number, result?: Point3d): undefined | Point3d Multiply the point by the inverse Transform.  
multiplyPoint2d(point: Readonly<WritableXAndY>, result?: Point2d): Point2d Transform the input 2d point (using Tp = M*p + o).  
multiplyPoint2dArray(points: Point2d[], result?: Point2d[]): Point2d[] Transform the input 2d point array (using Tp = M*p + o).  
multiplyPoint3d(point: Readonly<WritableXYAndZ>, result?: Point3d): Point3d Transform the input 3d point (using Tp = M*p + o).  
multiplyPoint3dArray(points: Point3d[], result?: Point3d[]): Point3d[] Transform the input 3d point array (using Tp = M*p + o).  
multiplyPoint3dArrayArrayInPlace(chains: Point3d[][]): void For each point in the 2d array, replace point by the transformed point (using Tp = M*p + o)  
multiplyPoint3dArrayInPlace(points: Point3d[]): void For each point in the array, replace point by the transformed point (using Tp = M*p + o)  
multiplyRange(range: Range3d, result?: Range3d): Range3d Return the range of the transformed corners.  
multiplyTransformMatrix3d(other: Matrix3d, result?: Transform): Transform Multiply this Transform times other Matrix3d (considered to be a Transform with 0 origin).  
multiplyTransformTransform(other: Transform, result?: Transform): Transform Multiply this Transform times other Transform.  
multiplyTransposeXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d Multiply the homogeneous point by the transpose of this Transform.  
multiplyVector(vector: Vector3d, result?: Vector3d): Vector3d Multiply the vector by the matrix part of the Transform.  
multiplyVectorInPlace(vector: Vector3d): void Multiply the vector by the matrix part of the Transform in place.  
multiplyVectorXYZ(x: number, y: number, z: number, result?: Vector3d): Vector3d Multiply the vector (x,y,z) by the matrix part of the Transform.  
multiplyXYAndZInPlace(point: Readonly<WritableXYAndZ>): void Transform the input 3d point in place (using Tp = M*p + o).  
multiplyXYZ(x: number, y: number, z: number0, result?: Point3d): Point3d Transform the input 3d point (using Tp = M*p + o).  
multiplyXYZToFloat64Array(x: number, y: number, z: number, result?: Float64Array): Float64Array * Transform the point.  
multiplyXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d Transform the homogeneous point.  
multiplyXYZWToFloat64Array(x: number, y: number, z: number, w: number, result?: Float64Array): Float64Array Transform the homogeneous point.  
setFrom(other: Transform): void Copy contents from other Transform into this Transform  
setFromJSON(json?: TransformProps | Transform): void Set this Transform instance from flexible inputs:  
setIdentity(): void Set this Transform to be an identity.  
setMultiplyTransformTransform(transformA: Transform, transformB: Transform): void Calculate transformA * transformB and store it into the calling instance (this).  
setOriginAndMatrixColumns(origin: XYZ, vectorX: Vector3d, vectorY: Vector3d, vectorZ: Vector3d): void Create a Transform using the given origin and columns of the matrix.  
toJSON(): TransformProps Return a 3 by 4 matrix containing the rows of this Transform.  
toRows(): number[][] Return a 3 by 4 matrix containing the rows of this Transform.  
createFixedPointAndMatrix(fixedPoint: Readonly<WritableXYAndZ>, matrix: Matrix3d, result?: Transform): Transform Static Create a Transform with the specified matrix.  
createFlattenAlongVectorToPlane(sweepVector: Vector3d, planePoint: Readonly<WritableXYAndZ>, planeNormal: Vector3d): undefined | Transform Static Return a transformation which flattens space onto a plane, sweeping along a direction which may be different from the plane normal.  
createIdentity(result?: Transform): Transform Static Create an identity transform  
createMatrixPickupPutdown(matrix: Matrix3d, a: Point3d, b: Point3d, result?: Transform): Transform Static Create a transform with the specified matrix and points a and b.  
createOriginAndMatrix(origin: XYZ, matrix: Matrix3d, result?: Transform): Transform Static Create a Transform using the given origin and matrix.  
createOriginAndMatrixColumns(origin: XYZ, vectorX: Vector3d, vectorY: Vector3d, vectorZ: Vector3d, result?: Transform): Transform Static Create a Transform using the given origin and columns of the matrix  
createRefs(origin: XYZ, matrix: Matrix3d, result?: Transform): Transform Static Create a Transform with the given origin and matrix.  
createRigidFromOriginAndColumns(origin: XYZ, vectorX: Vector3d, vectorY: Vector3d, axisOrder: AxisOrder, result?: Transform): undefined | Transform Static Create a Transform such that its matrix part is rigid.  
createRowValues(qxx: number, qxy: number, qxz: number, ax: number, qyx: number, qyy: number, qyz: number, ay: number, qzx: number, qzy: number, qzz: number, az: number, result?: Transform): Transform Static Create a Transform with complete contents given.  
createScaleAboutPoint(fixedPoint: Point3d, scale: number, result?: Transform): Transform Static Create a Transform which leaves the fixedPoint unchanged and scales everything else around it by  
createTranslation(translation: XYZ, result?: Transform): Transform Static Create a Transform with specified translation part.  
createTranslationXYZ(x: number0, y: number0, z: number0, result?: Transform): Transform Static Create a Transform with translation provided by x,y,z parts.  
createZero(result?: Transform): Transform Static Create a Transform with all zeros  
fromJSON(json?: TransformProps): Transform Static Return a new Transform initialized by Transform.setFromJSON  
initFromRange(min: Point3d, max: Point3d, npcToGlobal?: Transform, globalToNpc?: Transform): void Static Initialize 2 Transforms that map between the unit box (specified by 000 and 111) and the range box specified  
matchArrayLengths(source: any[], dest: any[], constructionFunction: () => any): number Static Match the length of destination array with the length of source array  

Properties

Name Type Description
identity Accessor Static ReadOnly Transform The identity Transform.  
isIdentity Accessor ReadOnly boolean test if the transform has origin = (0,0,0) and identity matrix  
matrix Accessor ReadOnly Matrix3d Return a reference (and NOT a copy) to the matrix part of the Transform.  
origin Accessor ReadOnly XYZ Return a reference (and NOT a copy) to the origin part of the Transform.  

Defined in

Last Updated: 13 June, 2024