So let me get this straight...
You have two (potentially skew - they may not intersect in 3D space) lines L1-3 and L2-3 in 3D space.
It's not "potentially"... they _definitely_ intersect. There will never be a case where these lines do not intersect. They can also never be parallel. This can be made an assumption in the maths used.
Also I'd probably call them L1-2, and L3-4. Where 1 and 2 are coordinates forming line L1-2, and 3 and 4 and two other coordinates that define line L3-4.
L1-2 and L3-4 definitely intersect.
Also note that these are lines rather than line segments. :>
These are projected onto a 2D plane (the screen) to give lines L1-2 and L2-2.
Yes that's right. :> The screen is a 2D plane defined by Z=0. However this is only relevant in that it gives me my 4th coordinate in order to form a line.
To give some background, at this point we have already determined that, in 2D, the line we are checking intersects the line we are checking against.
The X and Y coordinates of that 2D intersection point are now known.
To get the Z coordinate, recall that all 2D action effectively takes place on the flat plane Z=0. So Z = 0 is our third coordinate.
Now we have an X, Y, and Z coordinate; we then draw an imaginary line from the camera toward this X, Y and Z coordinate.
If you imagine this in your head, it's clear that the line we draw MUST intersect both of the other lines in 3D. We calculate the 3D intersection point for the first line, then the second line, then compare them to see which is furthest from the camera. Whichever one is furthest has a pseudovertex added...provided the pseudovertex isn't obscured behind another face.
Anyway, that's all pie in the sky right now; rather complicated stuff to try and explain, and not really necessary to understand the specific problem I'm having.
You want to know the point (X,Y) where the two projected lines intersect on the plane.
Nope, forget the screen/plane for now.
I have two 3D lines.
I know 2 coordinates on both lines (4 coordinates total).
I know that they intersect.
I need to find the 3D coordinates of where they intersect.
After finding this information, you want to know which of the 3D-space lines is closer to the camera at the point. If these lines L1-3 and L2-3 are skew they will pass through the points (X,Y,Z1) and (X,Y, Z2) respectively. You need to find which of the values Z1 and Z2 is smallest, as the smaller value will mean the line is closer to the camera at that point. If Z1 == Z2, then the lines intersect in 3D space and (I think) this will pose no problem.
Am I right, or have I missed something somewhere?
You're sort of on the right track with this last bit, but I have my own plans for how to handle the comparisons later down the line - code for lots of it has already been written.
For now, I only want to find out the coordinates of where those two lines intersect.