Reference transformPoint()

transformPoint()

This API is experimental

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

Applies a p5.strands transform to a position.

A transform is a matrix, and moving a point with it means multiplying the two together. Doing that by hand needs an extra 1 tacked onto the end of the position first, and the extra component stripped off the answer. transformPoint() takes care of both steps.

With a 2D transform from transform2D(), pass a two-component position and a two-component position comes back. With a 3D transform from transform3D(), pass a three-component position and a three-component position comes back.

Use transformNormal() for surface directions instead, since those must ignore the move part of a transform.

Note: transformPoint() can only be used inside a p5.strands shader callback.

Examples

Syntax

transformPoint(transform, point)

Parameters

transform
a transform created with transform2D() or transform3D().
point
the position to move.

Returns

the moved position, with as many components as the one passed in.

Related References