Skip to content

Point

a 3-dimensional point

x instance-attribute

x: float

y instance-attribute

y: float

z instance-attribute

z: float

distance_to

distance_to(other: Point) -> float

calculates the distance between this point and another given point.

Source code in src/specklepy/objects/geometry/point.py
def distance_to(self, other: "Point") -> float:
    """
    calculates the distance between this point and another given point.
    """
    if not isinstance(other, Point):
        raise TypeError(f"Expected Point object, got {type(other)}")

    # we assume that host application units are the same for both points
    # unit conversion could be expensive, so we avoid it here
    dx = other.x - self.x
    dy = other.y - self.y
    dz = other.z - self.z

    return (dx * dx + dy * dy + dz * dz) ** 0.5