Name

add()

Examples
v1 = PVector(40, 20, 0)
v2 = PVector(25, 50, 0)

ellipse(v1.x, v1.y, 12, 12)
ellipse(v2.x, v2.y, 12, 12)
v2.add(v1)
ellipse(v2.x, v2.y, 24, 24)
v = PVector(40, 20, 0)
ellipse(v.x, v.y, 12, 12)
ellipse(25, 50, 12, 12)
v.add(25, 50, 0)
ellipse(v.x, v.y, 24, 24)
v1 = PVector(40, 20, 0)
v2 = PVector(25, 50, 0)

ellipse(v1.x, v1.y, 12, 12)
ellipse(v2.x, v2.y, 12, 12)
v3 = PVector.add(v1, v2)
ellipse(v3.x, v3.y, 24, 24)
Description Adds x, y, and z components to a vector, adds one vector to another, or adds two independent vectors together. The version of the method that adds two vectors together is a static method and returns a PVector, the others have no return value -- they act directly on the vector. See the examples for more context.
Syntax
.add(v)
.add(x, y, z)
.add(v1, v2)
.add(v1, v2, target)
Parameters
vPVector: the vector to be added
xfloat: x component of the vector
yfloat: y component of the vector
zfloat: z component of the vector
v1PVector: a vector
v2PVector: another vector
targetPVector: the target vector (if null, a new vector will be created)

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.