Reference rotateAxisAngle()

rotateAxisAngle()

This API is experimental

Its behavior may change in a future version of p5.js.

Turns a 3D p5.strands transform about any axis.

rotateX(), rotateY(), and rotateZ() only turn about the three main axes. rotateAxisAngle() turns about a line pointing in any direction, given as a three-component vector. The axis doesn't need to be a unit vector; it is normalized before use.

A new transform is returned and the one passed in is left untouched, so the result has to be assigned back, as in t = rotateAxisAngle(t, [1, 1, 0], PI / 4).

Angles are always measured in radians here, since angleMode() doesn't reach inside a shader.

Note: rotateAxisAngle() only works on a transform created with transform3D(), and can only be used inside a p5.strands shader callback.

Examples

Syntax

rotateAxisAngle(transform, axis, angle)

Parameters

transform
a transform created with transform3D().
axis
a three-component vector pointing along the line to turn about.
angle
Number: angle to turn by, in radians.

Returns

a new transform with the turn applied.

Related References