Created
September 1, 2021 23:31
-
-
Save RedForty/6a1f40896e1bf53f4df63611294aa32c to your computer and use it in GitHub Desktop.
Get distance between two vectors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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