Applies a 4x4 matrix, or a list of matrices applied first to last, to a shape.
The matrix is column-major, so the translation sits at indices 12 to 14. A matrix that
stretches or shears is allowed; build matrices with the ...ToMatrix methods and combine
them with multiplyTransforms. A matrix the kernel cannot apply throws an error.
The shape and the matrix or list of matrices
The transformed shape
const move = await bitbybit.occt.transforms.translationToMatrix({ translation: [10, 0, 0] });
const turn = await bitbybit.occt.transforms.rotationAxisAngleToMatrix({ axis: [0, 1, 0], angle: 90, center: [0, 0, 0] });
const placed = await bitbybit.occt.transforms.transformByMatrix({ shape: box, transformation: [turn, move] });
Applies the same 4x4 matrix, or list of matrices applied first to last, to several shapes, as
transformByMatrix does for one.
The shapes and the matrix or list of matrices
The transformed shapes, in the same order
Reads the placement a shape carries, the transform stored on it rather than baked into its geometry, as a matrix plus its translation, rotation quaternion and uniform scale.
A shape placed with align or through an assembly carries such a placement; most other
methods here bake the move into the geometry, and such a shape reports the identity.
The shape to read
The matrix, the translation, the quaternion as [x, y, z, w] and the scale
Builds the identity matrix, the transform that changes nothing, as a starting point for composing others.
The identity matrix, column-major
Builds one matrix from a translation, three rotation angles in degrees about X, Y and Z, and a uniform scale.
The scale is applied first, then the rotations (Z first, then Y, then X), then the translation, which is the order assembly placements use. Any part left out is taken as no change.
The translation, the three rotation angles in degrees and the scale factor
The combined matrix, column-major
Folds a list of matrices into one, applied first to last, so a chain of moves becomes a single matrix.
A single matrix is returned unchanged and an empty list gives the identity.
The matrix or list of matrices
The combined matrix, column-major
Inverts a matrix, giving the transform that undoes it: applying a matrix and then its inverse puts a shape back where it was.
The matrix to invert
The inverse matrix, column-major
Builds the matrix of a move by a vector, in model units.
The translation vector
The translation matrix, column-major
Builds the matrix of a rotation by an angle in degrees about an axis, through the origin or through an optional center point.
The rotation follows the right-hand rule about axis.
The axis direction, the angle in degrees and the optional point the axis passes through
The rotation matrix, column-major
Builds the matrix of a uniform scale by a factor about the origin or an optional center point.
The factor and the optional point to scale about
The scale matrix, column-major
Builds the matrix of a mirror through a point, the transform mirrorAboutPoint applies.
The point to mirror through
The mirror matrix, column-major
Builds the matrix of a mirror across a line, the transform mirror applies: the axis through
origin along direction.
A point on the axis and the axis direction
The mirror matrix, column-major
Builds the matrix of a mirror across a plane, the transform mirrorAlongNormal applies: the
plane through origin with the given normal.
A point on the plane and the plane's normal
The mirror matrix, column-major
Builds the rotation matrix of a quaternion given as [x, y, z, w].
The quaternion is normalized first, so its length does not matter.
The quaternion
The rotation matrix, column-major
Applies transform to several shapes, each with its own translation, rotation axis, angle
and scale factor.
All the lists must have the same length, or an error is thrown.
The shapes and one translation, rotation axis, angle in degrees and scale factor per shape
The transformed shapes, in the same order
Applies rotate to several shapes, each about its own axis through the origin and by its own
angle in degrees.
All the lists must have the same length, or an error is thrown.
The shapes and one axis and angle per shape
The rotated shapes, in the same order
Applies rotateAroundCenter to several shapes, each with its own angle in degrees, center
and axis.
All the lists must have the same length, or an error is thrown.
The shapes and one angle, center and axis per shape
The rotated shapes, in the same order
Applies align to several shapes, each with its own from and to frames.
All the lists must have the same length, or an error is thrown.
The shapes and one from origin, from direction, to origin and to direction per shape
The aligned shapes, in the same order
Applies alignAndTranslate to several shapes, each with its own direction and center.
All the lists must have the same length, or an error is thrown.
The shapes and one direction and center per shape
The placed shapes, in the same order
Applies translate to several shapes, each by its own vector.
The two lists must have the same length, or an error is thrown.
The shapes and one translation vector per shape
The moved shapes, in the same order
Applies scale to several shapes, each uniformly about the origin by its own factor.
The two lists must have the same length, or an error is thrown.
The shapes and one factor per shape
The scaled shapes, in the same order
Applies scale3d to several shapes, each with its own three factors and center.
All the lists must have the same length, or an error is thrown.
The shapes and one scale vector and center per shape
The scaled shapes, in the same order
Applies mirror to several shapes, each across its own axis.
All the lists must have the same length, or an error is thrown.
The shapes and one axis origin and direction per shape
The mirrored shapes, in the same order
Applies mirrorAlongNormal to several shapes, each across its own plane.
All the lists must have the same length, or an error is thrown.
The shapes and one plane origin and normal per shape
The mirrored shapes, in the same order
Scales, rotates and moves a shape in one go: first the scale about the origin, then the rotation about an axis through the origin, then the translation.
Because the scale and the rotation happen about the origin, a shape that is not there also
swings around it; move it first, or use rotateAroundCenter and scale3d for a chosen
center.
The shape, the translation, the rotation axis and angle in degrees, and the scale factor
The transformed shape
Rotates a shape about an axis that passes through the origin, by an angle in degrees.
The rotation follows the right-hand rule: with the thumb along axis, the fingers show the
positive direction. A shape away from the origin swings around it; rotateAroundCenter
rotates about a chosen point instead.
The shape, the axis direction and the angle in degrees
The rotated shape
Rotates a shape about an axis that passes through a chosen point, by an angle in degrees.
The shape is moved so the point sits at the origin, rotated there with the right-hand rule
about axis, and moved back.
The shape, the angle in degrees, the point the axis passes through and the axis direction
The rotated shape
Moves a shape so that one point and direction on it land on another point and direction: the
frame fromOrigin with fromDirection is carried onto toOrigin with toDirection.
This is the way to stand a shape on a surface or point it along a line: the shape is both moved and turned, never scaled.
The shape, the point and direction to take from, and the point and direction to land on
The aligned shape
Moves a shape so that a full frame on it lands on another frame: a point, its normal and one axis in the plane of that normal are carried onto their targets.
Where align fixes one direction and leaves the spin around it free, this also fixes the
spin, which matters for shapes that are not round about their axis.
The shape, the point, normal and axis to take from, and the point, normal and axis to land on
The aligned shape
Turns a shape so that its Y axis points along direction, then moves it to center.
The flat shapes and primitives of this package are built on the ground with Y up, so this is the one call that places any of them: the direction becomes their new up, and the center where they sit.
The shape, the direction its Y axis should point along and the point to move it to
The placed shape
Moves a shape by a vector, in model units.
The shape and the vector to move it by
The moved shape
Scales a shape uniformly about the origin by a factor.
A shape away from the origin also moves away from or toward it; scaleFromCenter scales
about a chosen point and scale3d scales each axis by its own factor.
The shape and the factor
The scaled shape
Scales a shape by a separate factor along X, Y and Z, about a chosen center point.
Unequal factors stretch the shape, which turns circles into ellipses and can make later operations, such as fillets, slower or fail; keep the factors equal when the shape only needs to grow.
The shape, the three factors and the point to scale about
The scaled shape
Mirrors a shape across a line: the axis through origin along direction.
Every point lands as far behind the line as it was in front, which in 3D is the same as a half turn about that axis.
The shape, a point on the axis and the axis direction
The mirrored shape
Mirrors a shape across a plane given by a point on it and its normal.
This is the usual mirror image, the kind a symmetric part needs; the result is turned inside out in the sense that a left-hand shape becomes a right-hand one.
The shape, a point on the mirror plane and the plane's normal
The mirrored shape
Scales a shape uniformly about a chosen point by a factor.
The point stays where it is and everything else moves away from it or toward it.
The shape, the factor and the point to scale about
The scaled shape
Mirrors a shape through a point: every point of the shape lands as far beyond the point as it was before it, on the opposite side.
The result is turned inside out, the way a plane mirror turns a left hand into a right hand.
The shape and the point to mirror through
The mirrored shape
Rotates a shape about the origin by a quaternion given as [x, y, z, w].
The quaternion is normalized first, so its length does not matter. Quaternions are what animation and physics libraries hand out, so this saves converting them to an axis and an angle.
The shape and the quaternion
The rotated shape
Moving, turning, scaling and mirroring OpenCascade shapes, and building the 4x4 matrices that describe such moves. Every method returns a new shape and leaves the input as it was. Angles are in degrees, distances in model units, and a rotation axis passes through the origin unless a method takes a center. Matrices are 16 numbers in column-major order (the translation sits at indices 12 to 14); a list of matrices is applied first to last as one combined move, which is how
transformByMatrixand the...ToMatrixbuilders fit together.