Hypot Function - Python Math Module

Method name:

hypot(aPointX_in, aPointY_in)

Method overview:

hypot() function from the math module of python, calculates and returns the Euclidian Distance
between the origin(0,0) and a specified point. The value returned is also called as the 
Euclidian Norm.

It is square root of the sume of the two values: Square of X coordinate value  and Square Y coordinate value.

Parameters:

aPointX_in : X coordinate value
aPointY_in : Y coordinate value

Return value:

The distance from origin to the point at location(x,y)

Example:

import math

 

PointA = (5,5) #A point tuple

distance = round(math.hypot(PointA[0],PointA[1]),2)

print("Euclidian distance between origin and PointA:{}".format(distance))

 

#Find the X Intercept distance of a point

XIntercept = (7,0) #A point that falls exactly on X axis

XInterceptDistance = math.hypot(XIntercept[0],XIntercept[1])

print("Euclidian distance between origin and X Intercept:{}".format(XInterceptDistance))

 

#Find the Y Intercept distance of a point

YIntercept = (0,5) #A point that falls exactly on Y axis

YInterceptDistance = math.hypot(YIntercept[0],YIntercept[1])

print("Euclidian distance between origin and Y Intercept:{}".format(YInterceptDistance))

Output:

Euclidian distance between origin and PointA:7.07

Euclidian distance between origin and X Intercept:7.0

Euclidian distance between origin and Y Intercept:5.0


Copyright 2022 © pythontic.com