Py5Vector.dist()

Calculate the distance between two vectors.

Examples

example picture for dist()
1
2
3
4
5
6
def setup():
    py5.background(128)
    v1 = py5.Py5Vector(22.8, 31.4)
    v2 = py5.Py5Vector(87.2, 72.4)
    py5.line(v1.x, v1.y, v2.x, v2.y)
    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