参考 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. Any missing parameters are assigned the value 0.

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

示例

语法

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

参数

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.

v1
p5.Vector|Array:

the first vector to compare

v2
p5.Vector|Array:

the second vector to compare

Returns

Boolean: whether the vectors are equal.
Notice any errors or typos? Please let us know. Please feel free to edit src/math/p5.Vector.js and open a pull request!

相关参考