Reference set()

set()

Sets the vector's x, y, and z components.

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

If a value isn't provided for a component, it will be set to 0. For example, v.set(4, 5) sets v.x to 4, v.y to 5, and v.z to 0. Calling set() with no arguments, as in v.set(), sets all the vector's components to 0.

Examples

Syntax

set([x], [y], [z])
set(value)

Parameters

x
Number:

x component of the vector.

y
Number:

y component of the vector.

z
Number:

z component of the vector.

value
p5.Vector|Number[]:

vector to set.

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