This is probably the wrong place to ask but...

How do you know if two lines intersects in 2D if you know the two vectors of the lines? And, in that case, how do you know where they intersect?
Posted on 2002-01-30 00:43:47 by gliptic
Posted on 2002-01-30 01:05:33 by bitRAKE
Thanks! Does any of you have this coded down in ASM? I have troubles getting it right. I guess I haven't done vector math for some time.
Posted on 2002-01-30 01:12:27 by gliptic
For a simple concept think of two two dimensional arrays:


array1[100][100] - Initialize To Zero
array2[100][100] - Initialize To Zero

let's say line1 is a diagonal, so Array1[0+ecx][0+ecx] ... inc ecx until it's 99.

/ <- Starting Point

And line2 is a straight vertical line(Array2[0][0+ecx] ) ... inc ecx until it's 99.

|<- Starting Point

Output in this example is

| /
| /

In this case:

Array1[0][0] = 1 (Not Zero To Signify A Line - Imaginary)
Array1[1][1] = 1
Array1[2][2] = 1
Array1[99][99] = 1


Array2[0][0] = 1
Array2[0][1] = 1
Array2[0][2] = 1
Array2[0][99] = 1

All parts of the arrays are 0 except the ones mentioned above. Notice that only Array1[0][0] == 1 and Array2[0][0] == 1 are both equal -> This is the intersection point.

I hope you can pick up the idea... :)
Posted on 2002-01-30 01:21:15 by stryker
Well that will work but it's not mathematically correct nor it is fast. I have read a little more and I'm now able to understand the formula on the page BitRAKE (or is it BitRACK? :) ) gave me.
Posted on 2002-01-30 03:55:21 by gliptic
Heres one I wrote a while ago, Call it through the Macro passing the x,y coords of the 4 ends of each line segment and it will return 1 if the lines intersect, 0 if they don't.

Posted on 2002-01-30 07:02:47 by Eóin