transform.rotation
The rotation by an angle about an axis through a centre, counter-clockwise by the right-hand rule.
Usage
Transform.rotation(angleRad: number, axis: Vector3, center?: Point3): Transform | nullParameters
angleRadnumberThe angle; positive is counter-clockwise when the axis points at the viewer. Required. In radians.
axisVector3The axis direction; any non-zero length. Required. In model.
centerPoint3A point on the axis; it stays fixed. Default
Point3.origin. In model.
Returns
A frozen rigid transform; null when axis has no direction (zero length or not finite). A non-finite angle gives a transform for which Transform.isFinite is false.
Guarantees
- center is fixed (Transform.applyToPoint(xf, center) ≈ center)
- distances are preserved (Point3.distance of any two transformed points ≈ the original)
- the axis is unchanged (Transform.applyToVector(xf, axis) ≈ axis)
- The same result on every machine.
Example
const r = Transform.rotation(Math.PI / 2, Vector3.zAxis)
Transform.applyToPoint(r, Point3.of(1, 0, 0)) // → { x: ≈0, y: 1, z: 0 }
Transform.rotation(1, Vector3.zero) // → null