Show:
Module: p5.play
Parent Module: p5.play

Methods

isParallel
(
  • v2
  • tolerance
)
Boolean

Defined in lib/p5.play.js:373

Ask whether a vector is parallel to this one.

Parameters:

  • v2 p5.Vector
  • [tolerance] Number optional
    • margin of error for comparisons, comes into play when comparing rotated vectors. For example, we want <1, 0> to be parallel to <0, 1>.rot(Math.PI/2) but float imprecision can get in the way of that.

Returns:

Boolean
transform
(
  • transform
)
p5.Vector

Defined in lib/p5.play.js:6378

Transforms this vector by a 2D transformation matrix.

Parameters:

Returns:

p5.Vector:

this, after the change

Static Methods

p5.Vector.project
(
  • a
  • b
)
p5.Vector

Defined in lib/p5.play.js:358

Projects a vector onto the line parallel to a second vector, giving a third vector which is the orthogonal projection of that vector onto the line.

Parameters:

  • a p5.Vector
    • vector being projected
  • b p5.Vector
    • vector defining the projection target line.

Returns:

p5.Vector:

projection of a onto the line parallel to b.

p5.Vector.transform
(
  • v
  • t
)
p5.Vector

Defined in lib/p5.play.js:6364

Applies a 2D transformation matrix (using homogeneous coordinates, so 3x3) to a Vector2 (<x, y, 1>) and returns a new vector2.

Parameters:

Returns:

p5.Vector:

a new vector