Alex Rivera | Logout

How do I know if two vectors are near parallel

Asked 2011-09-27T16:38:55.317
12

I am having some trouble finding parallel vectors because of floating point precision. How can I determine if the vectors are parallel with some tolerance?

I also need a check for orthogonality with tolerance.

Edit
Report

1 Answer

18

For vectors v1 and v2 check if they are orthogonal by

abs(scalar_product(v1,v2)/(length(v1)*length(v2))) < epsilon

where epsilon is small enough. Analoguously you can use

scalar_product(v1,v2)/(length(v1)*length(v2)) > 1 - epsilon

for parallelity test and

scalar_product(v1,v2)/(length(v1)*length(v2)) < -1 + epsilon

for anti-parallelity.

answered 2011-09-27T16:41:26.887

Your Answer