mult()

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.

예제

구문

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])

매개변수

n
Number:

The number to multiply with the vector

x
Number:

number to multiply with the x component of the vector.

y
Number:

number to multiply with the y component of the vector.

z
Number:

number to multiply with the z component of the vector.

arr
Number[]:

array to multiply with the components of the vector.

v
p5.Vector:

vector to multiply with the components of the original vector.

target
p5.Vector:

vector to receive the result.

v0
p5.Vector:
v1
p5.Vector:
Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!

관련 레퍼런스