/** @packageDocumentation * @module CartesianGeometry */ import { AxisOrder, BeJSONFunctions } from "../Geometry"; import { Point4d } from "../geometry4d/Point4d"; import { Matrix3d } from "./Matrix3d"; import { Point2d } from "./Point2dVector2d"; import { Point3d, Vector3d, XYZ } from "./Point3dVector3d"; import { Range3d } from "./Range"; import { TransformProps, XAndY, XYAndZ } from "./XYZProps"; /** A transform is 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. * * Beware that for common transformations (e.g. scale about point, * rotate around line, mirror across a plane) 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. * @public */ export declare class Transform implements BeJSONFunctions { private static _scratchPoint; private _origin; private _matrix; private constructor(); private static _identity?; /** The identity Transform. Value is frozen and cannot be modified. */ static get identity(): Transform; /** Freeze this instance (and its members) so it is read-only */ freeze(): Readonly; /** * Copy contents from other Transform into this Transform * @param other source transform */ setFrom(other: Transform): void; /** Set this Transform to be an identity. */ setIdentity(): void; /** Set this Transform instance from flexible inputs: * * Any object (such as another Transform) that has `origin` and `matrix` members accepted by Point3d.setFromJSON and Matrix3d.setFromJSON * * An array of 3 number arrays, each with 4 entries which are rows in a 3x4 matrix. * * An array of 12 numbers, each block of 4 entries as a row 3x4 matrix. */ setFromJSON(json?: TransformProps | Transform): void; /** * Test for near equality with other Transform. Comparison uses the isAlmostEqual methods on * the origin and matrix parts. * @param other Transform to compare to. */ isAlmostEqual(other: Transform): boolean; /** * Test for near equality with other Transform. Comparison uses the isAlmostEqualAllowZRotation method of Matrix3d * the origin and matrix parts. * @param other Transform to compare to. */ isAlmostEqualAllowZRotation(other: Transform): boolean; /** Return a 3 by 4 matrix containing the rows of this Transform * * This transform's origin is the [3] entry of the json arrays */ toJSON(): TransformProps; /** Return a 3 by 4 matrix containing the rows of this Transform * * This transform's origin is the [3] entry of the json arrays */ toRows(): number[][]; /** Return a new Transform initialized by `setFromJSON (json)` */ static fromJSON(json?: TransformProps): Transform; /** Copy the contents of this transform into a new Transform (or to the result, if specified). */ clone(result?: Transform): Transform; /** Return a copy of this Transform, modified so that its axes are rigid * * The first axis direction named in axisOrder is preserved * * The plane of the first and second directions is preserved, and its vector in the rigid matrix has positive dot product with the corresponding vector if the instance * * The third named column is the cross product of the first and second. */ cloneRigid(axisOrder?: AxisOrder): Transform | undefined; /** Create a copy with the given origin and matrix captured as the Transform origin and Matrix3d. */ static createRefs(origin: XYZ | undefined, matrix: Matrix3d, result?: Transform): Transform; /** Create a transform with complete contents given */ static 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; /** Create a transform with all zeros. */ static createZero(result?: Transform): Transform; /** * create a Transform with translation provided by x,y,z parts. * @param x x part of translation * @param y y part of translation * @param z z part of translation * @param result optional result * @returns new or updated transform. */ static createTranslationXYZ(x?: number, y?: number, z?: number, result?: Transform): Transform; /** Create a matrix with specified translation part. * @param XYZ x,y,z parts of the translation. * @returns new or updated transform. */ static createTranslation(translation: XYZ, result?: Transform): Transform; /** Return a reference to the matrix within the transform. (NOT a copy) */ get matrix(): Matrix3d; /** Return a reference to the origin within the transform. (NOT a copy) */ get origin(): XYZ; /** return a (clone of) the origin part of the transform, as a Point3d */ getOrigin(): Point3d; /** return a (clone of) the origin part of the transform, as a Vector3d */ getTranslation(): Vector3d; /** test if the transform has 000 origin and identity Matrix3d */ get isIdentity(): boolean; /** Return an identity transform, optionally filling existing transform. */ static createIdentity(result?: Transform): Transform; /** Create by directly installing origin and matrix * this is a the appropriate construction when the columns of the matrix are coordinate axes of a local-to-global mapping * Note there is a closely related createFixedPointAndMatrix whose point input is the fixed point of the global-to-global transformation. */ static createOriginAndMatrix(origin: XYZ | undefined, matrix: Matrix3d | undefined, result?: Transform): Transform; /** Create by directly installing origin and columns of the matrix */ static createOriginAndMatrixColumns(origin: XYZ, vectorX: Vector3d, vectorY: Vector3d, vectorZ: Vector3d, result?: Transform): Transform; /** Create by with matrix from Matrix3d.createRigidFromColumns. * * Has careful logic for building up optional result without allocations. */ static createRigidFromOriginAndColumns(origin: XYZ | undefined, vectorX: Vector3d, vectorY: Vector3d, axisOrder: AxisOrder, result?: Transform): Transform | undefined; /** Reinitialize by directly installing origin and columns of the matrix */ setOriginAndMatrixColumns(origin: XYZ | undefined, vectorX: Vector3d | undefined, vectorY: Vector3d | undefined, vectorZ: Vector3d | undefined): void; /** Create a transform with the specified matrix. Compute an origin (different from the given fixedPoint) * so that the fixedPoint maps back to itself. */ static createFixedPointAndMatrix(fixedPoint: XYAndZ | undefined, matrix: Matrix3d, result?: Transform): Transform; /** Create a transform with the specified matrix, acting on any `pointX `via * `pointY = matrix * (pointX - pointA) + pointB` * so that the fixedPoint maps back to itself. */ static createMatrixPickupPutdown(matrix: Matrix3d, pointA: Point3d, pointB: Point3d, result?: Transform): Transform; /** Create a Transform which leaves the fixedPoint unchanged and * scales everything else around it by a single scale factor. */ static createScaleAboutPoint(fixedPoint: Point3d, scale: number, result?: Transform): Transform; /** Transform the input 2d point. Return as a new point or in the pre-allocated result (if result is given) */ multiplyPoint2d(source: XAndY, result?: Point2d): Point2d; /** Transform the input 3d point. Return as a new point or in the pre-allocated result (if result is given) */ multiplyPoint3d(point: XYAndZ, result?: Point3d): Point3d; /** Transform the input object with x,y,z members */ multiplyXYAndZInPlace(point: XYAndZ): void; /** Transform the input point. Return as a new point or in the pre-allocated result (if result is given) */ multiplyXYZ(x: number, y: number, z?: number, result?: Point3d): Point3d; /** Multiply a specific row of the transform times xyz. Return the (number). */ multiplyComponentXYZ(componentIndex: number, x: number, y: number, z?: number): number; /** Multiply a specific row of the transform times (weighted!) xyzw. Return the (number). */ multiplyComponentXYZW(componentIndex: number, x: number, y: number, z: number, w: number): number; /** Transform the input homogeneous point. Return as a new point or in the pre-allocated result (if result is given) */ multiplyXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d; /** Transform the input homogeneous point. Return as a new point or in the pre-allocated result (if result is given) */ multiplyXYZWToFloat64Array(x: number, y: number, z: number, w: number, result?: Float64Array): Float64Array; /** Transform the input homogeneous point. Return as a new point or in the pre-allocated result (if result is given) */ multiplyXYZToFloat64Array(x: number, y: number, z: number, result?: Float64Array): Float64Array; /** Multiply the transposed transform (as 4x4 with 0001 row) by Point4d given as xyzw.. Return as a new point or in the pre-allocated result (if result is given) */ multiplyTransposeXYZW(x: number, y: number, z: number, w: number, result?: Point4d): Point4d; /** for each point: replace point by Transform*point */ multiplyPoint3dArrayInPlace(points: Point3d[]): void; /** for each point: replace point by Transform*point */ multiplyPoint3dArrayArrayInPlace(chains: Point3d[][]): void; /** Return product of the transform's inverse times a point. */ multiplyInversePoint3d(point: XYAndZ, result?: Point3d): Point3d | undefined; /** Inverse transform the input homogeneous point. * * Return as a new point or in the optional result. * * returns undefined if the matrix part if this Transform is singular. */ multiplyInversePoint4d(weightedPoint: Point4d, result?: Point4d): Point4d | undefined; /** Return product of the transform's inverse times a point (point given as x,y,z) */ multiplyInverseXYZ(x: number, y: number, z: number, result?: Point3d): Point3d | undefined; /** * * for each point: multiply transform * point * * if result is given, resize to match source and replace each corresponding pi * * if result is not given, return a new array. */ multiplyInversePoint3dArray(source: Point3d[], result?: Point3d[]): Point3d[] | undefined; /** * * for each point in source: multiply transformInverse * point in place in the point. * * return false if not invertible. */ multiplyInversePoint3dArrayInPlace(source: Point3d[]): boolean; /** * * Compute (if needed) the inverse of the matrix part, thereby ensuring inverse operations can complete. * * Return true if matrix inverse completes. * @param useCached If true, accept prior cached inverse if available. */ computeCachedInverse(useCached?: boolean): boolean; /** * * If destination has more values than source, remove the extras. * * If destination has fewer values, use the constructionFunction to create new ones. * @param source array * @param dest destination array, to be modified to match source length * @param constructionFunction function to call to create new entries. */ static matchArrayLengths(source: any[], dest: any[], constructionFunction: () => any): number; /** * * for each point: multiply transform * point * * if result is given, resize to match source and replace each corresponding pi * * if result is not given, return a new array. */ multiplyPoint2dArray(source: Point2d[], result?: Point2d[]): Point2d[]; /** * * for each point: multiply transform * point * * if result is given, resize to match source and replace each corresponding pi * * if result is not given, return a new array. */ multiplyPoint3dArray(source: Point3d[], result?: Point3d[]): Point3d[]; /** Multiply the vector by the Matrix3d part of the transform. * * * The transform's origin is not used. * * Return as new or result by usual optional result convention */ multiplyVector(vector: Vector3d, result?: Vector3d): Vector3d; /** Multiply the vector (x,y,z) by the Matrix3d part of the transform. * * * The transform's origin is not used. * * Return as new or result by usual optional result convention */ multiplyVectorXYZ(x: number, y: number, z: number, result?: Vector3d): Vector3d; /** multiply this Transform times other Transform. * ``` * equation * \begin{matrix} * \text{`this` transform with matrix part }\bold{A}\text{ and translation }\bold{a} & \blockTransform{A}{a}\\ * \text{`other` transform with matrix part }\bold{B}\text{ and translation part }\bold{b}\text{ promoted to block transform} & \blockTransform{B}{b} \\ * \text{product}& \blockTransform{A}{a}\blockTransform{B}{b}=\blockTransform{AB}{Ab + a} * \end{matrix} * ``` * @param other right hand transform for multiplication. * @param result optional preallocated result to reuse. */ multiplyTransformTransform(other: Transform, result?: Transform): Transform; /** * multiply transformA * transformB, store to calling instance. * @param transformA left operand * @param transformB right operand */ setMultiplyTransformTransform(transformA: Transform, transformB: Transform): void; /** multiply this Transform times other Matrix3d, with other considered to be a Transform with 0 translation. * ``` * equation * \begin{matrix} * \text{`this` transform with matrix part }\bold{A}\text{ and translation }\bold{b} & \blockTransform{B}{b}\\ * \text{`other` matrix }\bold{B}\text{ promoted to block transform} & \blockTransform{B}{0} \\ * \text{product}& \blockTransform{A}{a}\blockTransform{B}{0}=\blockTransform{AB}{a} * \end{matrix} * ``` * @param other right hand Matrix3d for multiplication. * @param result optional preallocated result to reuse. */ multiplyTransformMatrix3d(other: Matrix3d, result?: Transform): Transform; /** * Return the range of the transformed corners. * * The 8 corners are transformed individually. * * Note that if there is anything other than translation and principal axis scaling in the transform, the volume of the range rotation will increase. * * Hence to get a "tight" range on rotated geometry, a range computation must be made on the rotated geometry itself. */ multiplyRange(range: Range3d, result?: Range3d): Range3d; /** * * Return a Transform which is the inverse of this transform. * * Return undefined if this Transform's matrix is singular. */ inverse(): Transform | undefined; /** Initialize transforms that map each direction of a box (axis aligned) to `[0,1]`. * * The corner coordinates do _not_ need to be in order in any of the x,y,z directions. * * The npcToGlobalTransform (if supplied) maps 000 to the point named point000. * * The npcToGlobalTransform (if supplied) maps 11 to the point named point000. * * The globalToNpc transform is the inverse. * @param min the "000" corner of the box * @param max the "111" corner of the box * @param npcToGlobal (object created by caller, re-initialized here) transform that carries 01 coordinates into the min,max box. * @param globalToNpc (object created by caller, re-initialized here) transform that carries world coordinates into 01 */ static initFromRange(min: Point3d, max: Point3d, npcToGlobal?: Transform, globalToNpc?: Transform): void; } //# sourceMappingURL=Transform.d.ts.map