Py5Vector.dist()#

Calculate the distance between two vectors.

Examples#

example picture for dist()
1def setup():
2    py5.background(128)
3    v1 = py5.Py5Vector(22.8, 31.4)
4    v2 = py5.Py5Vector(87.2, 72.4)
5    py5.line(v1.x, v1.y, v2.x, v2.y)
6    py5.text(f'dist = {v1.dist(v2):.2f}', 5, 15)

Description#

Calculate the distance between two vectors.

Syntax#

dist(other: Union[Py5Vector, np.ndarray]) -> Union[Py5Vector, np.ndarray[np.floating]]

Parameters#

  • other: Union[Py5Vector, np.ndarray] - vector to calculate the distance from

Updated on February 26, 2022 13:22:44pm UTC