Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,27 @@
def crossp(a, b):
'''Cross product of two 3D vectors'''
assert len(a) == len(b) == 3, 'For 3D vectors only'
a1, a2, a3 = a
b1, b2, b3 = b
return (a2*b3 - a3*b2, a3*b1 - a1*b3, a1*b2 - a2*b1)
def dotp(a,b):
'''Dot product of two eqi-dimensioned vectors'''
assert len(a) == len(b), 'Vector sizes must match'
return sum(aterm * bterm for aterm,bterm in zip(a, b))
def scalartriplep(a, b, c):
'''Scalar triple product of three vectors: "a . (b x c)"'''
return dotp(a, crossp(b, c))
def vectortriplep(a, b, c):
'''Vector triple product of three vectors: "a x (b x c)"'''
return crossp(a, crossp(b, c))
if __name__ == '__main__':
a, b, c = (3, 4, 5), (4, 3, 5), (-5, -12, -13)
print("a = %r; b = %r; c = %r" % (a, b, c))
print("a . b = %r" % dotp(a,b))
print("a x b = %r" % (crossp(a,b),))
print("a . (b x c) = %r" % scalartriplep(a, b, c))
print("a x (b x c) = %r" % (vectortriplep(a, b, c),))