   How to check if two vectors will intersects?
  Im having a problem on checking if two vectors will eventually intersects. I tried google but the math involved is above me. Is there a simple way to check this? I don't need to get the intersection point.   
  Vectors don't intersect.Lines may intersect if they are coplanar.2D/3D?Maybe you could post a drawing that shows what you mean by "intersection".   ;  2D vectors. Sorry about that. Im treating them as rays. So i would like to check if the given to rays will intersect.   ;  To define a ray you need a position and a direction thus 2 vectors per ray.As you work in 2D you only have to test the direction of those rays to determinewether they intersect or not.You only have to check if the direction is the same. If so the rays are paralleland can only have common points when its the same ray.If the direction vectors of the rays are not pointing in the same direction therays will intersect under all circumstances in 2D space.Two vectors are considered parallel when there is a factor lambda:a= lambda * bwith a and b being the vectors and lambda an element of R, so lambdacould be any number from positiv down to negativ infinity.[edit]If you got a dot-product implemented for this vectors and can guarantee thatboth direction vectors are normalized (have the length 1) you could performa*b which will be 1 or -1 if the direction vectors are parallel.   ;  @SpynackersThank you. So I just need the dot product of the direction vectors.   ;  AFAIK: The property is named "co-linear" if we're speaking of 2D constructs like lines. Parallelism is given if the lambda (from the post above) is positive, and anti-parallelism if it is negative.Strictly seen, the both direction vectors need not to be normalized when using the dot-product. The formulaa . b = |a| * |b| * cos( <a, b> )shows that the dot-product (symbolized by . as opposed to *) will be zero regardless of the length of the vectors if the angle between them is +/-90°.However, please notice that, on a computer, you suffer from the limited precision of number representations. It is likely that you find a hit point somewhere very far away. You may need to introduce some epsilon for the result of the dot-product.   ;  Well haegarr I did not want to get too "technical". ^^Most people I know will write the dot-product as <a,b>to make it distinct from other products but as it was clearin my post what was meant I just used the *.@GlaiveVehemYou should describe the problem you want to solve as whole notonly this part of parallelism so one can estimate which stepshave to be taken to fit into the whole problem.As haegarr pointed out the computer might consider two vectorsas parallel that are not or vice versa due to the limited accuracy offloatingpoint operations. If you only want to know wether two lines/raysdo not intersect within a certain "small" area this should not be the problem.If further steps in your algorithm depend on an existing intersection and itsposition you have to be aware that especially nearly parallel lines/rays maycreate hugely different intersection points with varying accuracy.   ;  I only came in here to see how many posts there would be before somebody says that vectors can't/don't intersect.It never ceases to amaze me how pedantic math people can be. The math boffin at the last place I worked spent years lecturing over and over about there being no such thing as "world space" to other game developers.Using my amazing powers of deduction that you are actually referring to "lines" given that they might possibly intersect, this code might help. Both routines actually return the intersection point if you need it.(Note that the routine returns a bool as if the lines are parallel or they just don't overlap, then the don't overlap, otherwise it fills in the intersection point passed by reference. I got this stuff from a book somewhere, but I've used them and know they work.tBOOLRZMath::GetLineIntersection (t2DLINE &Line1,t2DLINE &Line2,RZVector2 &Result){tF32a, b, c, d, x, y, det, lambda, mu;RZVector2*pP11,*pP12,*pP21,*pP22;pP11=&Line1.A;pP12=&Line1.B;pP21=&Line2.A;pP22=&Line2.B;// We must see if there exist lambda and mu such that:// lambda[P11, P12] = mu[P21, P22]  with  0 < lambda, mu < 1.// This give us two equations with two unknowns.// We set up a few parametersa = pP12->VX - pP11->VX;b = pP22->VX - pP21->VX;c = pP12->VY - pP11->VY;d = pP22->VY - pP21->VY;det = a * d - b * c; // determinant of equation matrix // det == 0 means that the edges are parallel.// We assume that they must not intersect in this case,// since 'overlapping' edges are dealt with beforehandif (Abs(det) < 0.00000001F)return FALSE;// If you do the maths, you discover that if lambda and mu exist, then// lambda = (dx - by) / det  and  mu = (cx - ay) / det// where  x = x21 - x11  and  y = y21 - y11x = pP21->VX - pP11->VX;y = pP21->VY - pP11->VY;lambda = (d * x - b * y) / det;if (lambda < 0 || lambda > 1)return FALSE;mu = (c * x - a * y) / det;if (mu < 0 || mu > 1)return FALSE;Result.VX=(Line1.B.VX-Line1.A.VX)*lambda;Result.VY=(Line1.B.VY-Line1.A.VY)*lambda;Result+=Line1.A;return TRUE;}EDIT: The code above tests for two lines of the given length. The following alteration allows for the lines to "flow out" infinitely longertBOOLRZMath::GetLineIntersection (t2DLINE &Line1,t2DLINE &Line2,RZVector2 &Result){tF32a, b, c, d, x, y, det, lambda, mu;RZVector2*pP11,*pP12,*pP21,*pP22;pP11=&Line1.A;pP12=&Line1.B;pP21=&Line2.A;pP22=&Line2.B;// We must see if there exist lambda and mu such that:// lambda[P11, P12] = mu[P21, P22]  with  0 < lambda, mu < 1.// This give us two equations with two unknowns.// We set up a few parametersa = pP12->VX - pP11->VX;b = pP22->VX - pP21->VX;c = pP12->VY - pP11->VY;d = pP22->VY - pP21->VY;det = a * d - b * c; // determinant of equation matrix // det == 0 means that the edges are parallel.// We assume that they must not intersect in this case,// since 'overlapping' edges are dealt with beforehandif (Abs(det) < 0.00000001F)return FALSE;// If you do the maths, you discover that if lambda and mu exist, then// lambda = (dx - by) / det  and  mu = (cx - ay) / det// where  x = x21 - x11  and  y = y21 - y11x = pP21->VX - pP11->VX;y = pP21->VY - pP11->VY;lambda = (d * x - b * y) / det;if (lambda < 0 || lambda > 1)return FALSE;mu = (c * x - a * y) / det;if (mu < 0 || mu > 1)return FALSE;Result.VX=(Line1.B.VX-Line1.A.VX)*lambda;Result.VY=(Line1.B.VY-Line1.A.VY)*lambda;Result+=Line1.A;return TRUE;};Quote:Original post by szecsVectors don't intersect.Lines may intersect if they are coplanar.2D/3D?Maybe you could post a drawing that shows what you mean by "intersection".2nd post;)   ;Intersection Code. I have ray to ray in there somewhere.   