Reference equals()

equals()

Checks whether all the vector's components are equal to another vector's.

equals() returns true if the vector's components are all the same as another vector's and false if not.

The version of equals() with one parameter interprets it as another p5.Vector object.

The version of equals() with multiple parameters interprets them as the components of another vector.

If the two vectors have different lengths, a warning is logged and only the components up to the shorter length are compared.

The static version of equals(), as in p5.Vector.equals(v0, v1), interprets both parameters as p5.Vector objects.

Examples

Syntax

equals([x], [y], [z])
equals(value)

Parameters

x
Number: x component of the vector.
y
Number: y component of the vector.
z
Number: z component of the vector.
value
p5.Vector|Array: vector to compare.

Returns

Boolean: whether the vectors are equal.

Related References