Skip to content

Instantly share code, notes, and snippets.

@RedForty
Created September 1, 2021 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedForty/6a1f40896e1bf53f4df63611294aa32c to your computer and use it in GitHub Desktop.
Save RedForty/6a1f40896e1bf53f4df63611294aa32c to your computer and use it in GitHub Desktop.
Get distance between two vectors
from math import pow, sqrt
def distance_between_vectors(a, b):
# Feed two vectors of type list3
# example: a = [0, 1, 2]
# Distance formula : ?((x2 - x1)2 + (y2 - y1)2 + (z2 - z1)2)
distance = sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2) + pow(a[2] - b[2], 2))
return distance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment