p5.Transform2D
A 2D affine transformation (translation, rotation, scale) stored as a 3x3 matrix that uses homogeneous coordinates. Used to quickly transform points or vectors between reference frames.
Table of Contents
Constructor
p5.Transform2D
-
source
Parameters:
-
[source]
p5.Transform2D | Array.optional
Methods
Reset this transform to an identity transform, in-place.
Returns:
this transform
equals
-
other
Check whether two transforms are the same.
Parameters:
-
other
p5.Transform2D | Array.
Returns:
getRotation
()
Number
Retrieve the angle of this transform in radians.
Returns:
Multiply this transform by another, combining them. Modifies this transform and returns it.
Parameters:
-
other
p5.Transform2D | Float32Array | Array.
Returns:
Modify this transform, rotating it by a certain amount.
Parameters:
-
radians
Number
Returns:
Modify this transform, scaling it by a certain amount. Returns this transform.
Returns:
Example:
// Three different ways to call this method.
var t = new p5.Transform();
// 1. One scalar value
t.scale(uniformScale);
// 1. Two scalar values
t.scale(scaleX, scaleY);
// 2. One vector
t.translate(new p5.Vector(scaleX, scaleY));
Modify this transform, translating it by a certain amount. Returns this transform.
Returns:
Example:
// Two different ways to call this method.
var t = new p5.Transform();
// 1. Two numbers
t.translate(x, y);
// 2. One vector
t.translate(new p5.Vector(x, y));
Static Methods
Multiply two transforms together, combining them. Does not modify original transforms. Assigns result into dest argument if provided and returns it. Otherwise returns a new transform.
Parameters:
-
t1
p5.Transform2D | Array. -
t2
p5.Transform2D | Array. -
[dest]
p5.Transform2D optional