math.hypot(*coordinates)
The math.hypot function returns the Euclidean norm of the vector that, having the center of coordinates as its origin, ends at the coordinates indicated as an argument. The result is equivalent to math.sqrt(sum(x ** 2 for x in coordinates)).
- coordinates: position x and y of the end of the vector whose norm is to be obtained.
We can obtain the norm of the vector that, having as origin the center of coordinates, ends at the point (1, 1) with the following code:
Of course, this norm is the same as that of the vector that ends, for example, at the coordinates (-1, 1):
We can verify that the previous result is equivalent to calculating the square root of the sum of the squares of the coordinates: