meteortools.utils.VectorMaths
1# Copyright (C) 2018-2023 Mark McIntyre 2 3# vector maths for comparing directions of meteors etc 4import numpy as np 5import math 6 7 8def shortestDistance(a, b, c, d): 9 # Lines are L=a+bt, M=c+ds 10 e = a - c 11 b2 = np.dot(b, b) 12 d2 = np.dot(b, b) 13 bd = np.dot(b, d) 14 de = np.dot(d, e) 15 be = np.dot(b, e) 16 db = np.dot(d, b) 17 18 A = -b2 * d2 + bd * bd 19 s = (-b2 * de + be * db) / A 20 t = (+d2 * be - de * db) / A 21 D = e + b * t - d * s 22 d = math.sqrt(np.dot(D, D)) 23 24 return s, t, d
def
shortestDistance(a, b, c, d):
9def shortestDistance(a, b, c, d): 10 # Lines are L=a+bt, M=c+ds 11 e = a - c 12 b2 = np.dot(b, b) 13 d2 = np.dot(b, b) 14 bd = np.dot(b, d) 15 de = np.dot(d, e) 16 be = np.dot(b, e) 17 db = np.dot(d, b) 18 19 A = -b2 * d2 + bd * bd 20 s = (-b2 * de + be * db) / A 21 t = (+d2 * be - de * db) / A 22 D = e + b * t - d * s 23 d = math.sqrt(np.dot(D, D)) 24 25 return s, t, d