transform.rotation

The rotation by an angle about an axis through a centre, counter-clockwise by the right-hand rule.

GeometricSince 0.3.0

Usage

TypeScript
Transform.rotation(angleRad: number, axis: Vector3, center?: Point3): Transform | null

Parameters

  • angleRadnumber

    The angle; positive is counter-clockwise when the axis points at the viewer. Required. In radians.

  • axisVector3

    The axis direction; any non-zero length. Required. In model.

  • centerPoint3

    A 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

TypeScript
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

See also