Reference rem()

rem()

Performs modulo (remainder) division with a vector's x, y, and z components.

rem() can use separate numbers, as in v.rem(1, 2, 3), another p5.Vector object, as in v.rem(v2), or an array of numbers, as in v.rem([1, 2, 3]).

If only one value is provided, as in v.rem(2), then all the components will be set to their values modulo 2. If two values are provided, as in v.rem(2, 3), then v.z won't change. Calling rem() with no arguments, as in v.rem(), has no effect.

The static version of rem(), as in p5.Vector.rem(v2, v1), returns a new p5.Vector object and doesn't change the originals.

Examples

Syntax

rem(x, y, z)
rem(value)
rem(v1, v2)
rem(v1, v2)

Parameters

x
Number:

x component of divisor vector.

y
Number:

y component of divisor vector.

z
Number:

z component of divisor vector.

value
p5.Vector | Number[]:

divisor vector.

v1
p5.Vector:

The dividend p5.Vector

v2
p5.Vector:

The divisor p5.Vector

This page is generated from the comments in src/math/p5.Vector.js . Please feel free to edit it and submit a pull request!

Related References