Subtracts from a vector's x, y, and z 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]).
If a value isn't provided for a component, it won't change. For example, v.sub(4, 5) subtracts 4 from v.x, 5 from v.y, and 0 from v.z. Calling sub() with no arguments, as in v.sub(), has no effect.
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)
sub(v1, v2, [target])
Parameters
x component of the vector to subtract.
y component of the vector to subtract.
z component of the vector to subtract.
the vector to subtract
A p5.Vector to subtract from
A p5.Vector to subtract
vector to receive the result.