Adds to a vector's components.
add() can use separate numbers, as in v.add(1, 2, 3), another p5.Vector object, as in v.add(v2), or an array of numbers, as in v.add([1, 2, 3]).
You should add vectors only when they are the same size. When two vectors of different sizes are added, the smaller dimension will be used, any additional values of the longer vector will be ignored. For example, adding [1, 2, 3] and [4, 5] will result in [5, 7].
Calling add() with no arguments, as in v.add(), has no effect.
This method supports N-dimensional vectors.
The static version of add(), as in p5.Vector.add(v2, v1), returns a new p5.Vector object and doesn't change the originals.
Examples
Syntax
add(x, [y], [z])
add(value)
Parameters
x
Number|Array: x component of the vector to be added or an array of components.
y
Number: y component of the vector to be added.
z
Number: z component of the vector to be added.
value
p5.Vector|Number[]: The vector to add
Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!