calc_hypotenuse_distance

pyhelpers.geom.calc_hypotenuse_distance(pt1, pt2)

Calculate hypotenuse given two points (the right-angled triangle, given its side and perpendicular).

See also [GEOM-CHD-1].

Parameters
  • pt1 (shapely.geometry.Point or list or tuple or numpy.ndarray) – a point

  • pt2 (shapely.geometry.Point or list or tuple or numpy.ndarray) – another point

Returns

hypotenuse

Return type

float

Note

  • This is the length of the vector from the orig_pt to dest_pt.

  • numpy.hypot(x, y) return the Euclidean norm, sqrt(x*x + y*y).

Examples:

>>> from pyhelpers.geom import calc_hypotenuse_distance
>>> from shapely.geometry import Point

>>> pt_1, pt_2 = (1.5429, 52.6347), (1.4909, 52.6271)
>>> hypot_distance = calc_hypotenuse_distance(pt_1, pt_2)
>>> hypot_distance
0.05255244999046248

>>> pt_1_, pt_2_ = map(Point, (pt_1, pt_2))
>>> pt_1_.wkt
'POINT (1.5429 52.6347)'
>>> pt_2_.wkt
'POINT (1.4909 52.6271)'
>>> hypot_distance = calc_hypotenuse_distance(pt_1_, pt_2_)
>>> hypot_distance
0.05255244999046248