Reference dot()

dot()

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
Number:

x component of the vector.

y
Number:

y component of the vector.

z
Number:

z component of the vector.

v
p5.Vector:

p5.Vector to be dotted.

v1
p5.Vector:

first p5.Vector.

v2
p5.Vector:

second p5.Vector.

Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!

Related References