Answers for "calculate euclidian distance python"

1

calculate euclidian distance python

from scipy.spatial import distance
a = (1, 2, 3)
b = (4, 5, 6)
dst = distance.euclidean(a, b)
Posted by: Guest on January-24-2022
1

none

dist = numpy.linalg.norm(a-b)
Posted by: Guest on July-12-2021
6

euclidean distance python

# I hope to be of help and to have understood the request
from math import sqrt # import square root from the math module
# the x and y coordinates are the points on the Cartesian plane
pointA = (x, y) # first point
pointB = (x, y) # second point
distance = calc_distance(pointA, pointB) # here your beautiful result
def calc_distance(p1, p2): # simple function, I hope you are more comfortable
  return sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2) # Pythagorean theorem
Posted by: Guest on June-06-2020

Code answers related to "calculate euclidian distance python"

Python Answers by Framework

Browse Popular Code Answers by Language