| 1 | initial version |
You can simply iterate over your list of vectors and search which vector gives a zero cross product with your target vector:
def search(L, target):
for i,v in enumerate(L):
if v.cross_product(target) == 0:
return i
raise ValueError('No vector found')
L = [vector([1,0,0]), vector([0,1,0]), vector([0,0,1])]
v= vector([6,0,0])
search(L, v)
0
search(L[1:], v)
ValueError: No vector found
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.