Calculates the dot product of two vectors.
The dot product is a number that describes the overlap between two vectors. Visually, the dot product can be thought of as the "shadow" one vector casts on another. The dot product's magnitude is largest when two vectors point in the same or opposite directions. Its magnitude is 0 when two vectors form a right angle.
The version of dot()
with one parameter interprets it as another p5.Vector object.
The version of dot()
with multiple parameters interprets them as the x
, y
, and z
components of another vector.
The static version of dot()
, as in p5.Vector.dot(v1, v2)
, is the same as calling v1.dot(v2)
.
Examples
Syntax
dot(x, [y], [z])
dot(v)
dot(v1, v2)
Parameters
x component of the vector.
y component of the vector.
z component of the vector.
p5.Vector to be dotted.
first p5.Vector.
second p5.Vector.