Multiplies a vector's x
, y
, and z
components.
mult()
can use separate numbers, as in v.mult(1, 2, 3)
, another p5.Vector object, as in v.mult(v2)
, or an array of numbers, as in v.mult([1, 2, 3])
.
If only one value is provided, as in v.mult(2)
, then all the components will be multiplied by 2. If a value isn't provided for a component, it won't change. For example, v.mult(4, 5)
multiplies v.x
by, v.y
by 5, and v.z
by 1. Calling mult()
with no arguments, as in v.mult()
, has no effect.
The static version of mult()
, as in p5.Vector.mult(v, 2)
, returns a new p5.Vector object and doesn't change the originals.
Examples
Syntax
mult(n)
mult(x, y, [z])
mult(arr)
mult(v)
mult(x, y, [z])
mult(v, n, [target])
mult(v0, v1, [target])
mult(v0, arr, [target])
Parameters
The number to multiply with the vector
number to multiply with the x component of the vector.
number to multiply with the y component of the vector.
number to multiply with the z component of the vector.
array to multiply with the components of the vector.
vector to multiply with the components of the original vector.
vector to receive the result.