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