How do I know if two vectors are near parallel

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.


If you have 3D vectors the answer is simple. Compute the cross product and if it is nearly zero, your vectors are nearly parallel: http://mathworld.wolfram.com/ParallelVectors.html

For 2d vectors you can convert them into 3D vectors just by adding a coordinate with zero (1;2) => (1;2;0), (4; 5.6) => (4; 5.6; 0) and so on

Two vectors are orthogonal or perpendicular, if there dot product ist zero: http://mathworld.wolfram.com/CrossProduct.html

-edit http://mathworld.wolfram.com/Perpendicular.html