Find intersection of two 3D lines I have two lines $(5,5,4) (10,10,6)$ and $(5,5,5) (10,10,3)$ with same $x$, $y$ and difference in $z$ values.
Please some body tell me how can I find the intersection of these lines.
EDIT: By using the answer given by coffemath I would able to find the intersection point for the above given points. But I'm getting a problem for $(6,8,4) (12,15,4)$ and $(6,8,2) (12,15,6)$. I'm unable to calculate the common point for these points as it is resulting in Zero.
Any ideas to resolve this?
Thanks, 
Kumar.
 A: The two lines can be represented as $(5,5,4)+s[(10,10,6)-(5,5,4)]$ and $(5,5,5)+t[(10,10,3)-(5,5,5)]$. To find their intersection means to find $s$ and $t$ such that they are equal.
A: There are at least two ways to approach such problems, through vectors as such and through coordinates.  Some problems are easier one way, and this one is definitely easier via coordinates.  Several such solutions have been given.  But the more ways you can solve a problem, the better you probably understand the underlying mathematics.  So I'll share a vector method.
We can arrive at the solution without the use of coordinates, except as a matter of calculation of the final answer.  We also assume that a line is given by a point and a (nonzero) direction vector (in either direction).  In the examples given, the lines are defined by two points, but a direction vector may be obtained by taking the difference in the coordinates of the two given points.
Here is the construction.  We leave the proof as an exercise, so that the interested reader may benefit by working it out (hint: the Law of Sines is helpful).
Let $\alpha$, $\beta$ be the given lines.
Let $C$, $D$ be points on $\alpha$, $\beta$, resp.  If $C$ is on $\beta$ or $D$ is on $\alpha$, we have found the point of intersection.  So let us assume they are not.
Let ${\bf e}$ and ${\bf f}$ be direction vectors of $\alpha$, $\beta$, resp.
Let ${\bf g} = \vec{CD}$.
Let $h = ||{\bf f} \times {\bf g}||$, $k=||{\bf f} \times {\bf e}||$.
If either is $0$, then there is no intersection; otherwise, they are nonzero and proceed.
Let ${\bf l} = {h \over k} {\bf e}$.
Then one of $M = C \pm {\bf l}$ is the point of intersection
(or depending on the notation you prefer, $\vec{OM} = \vec{OC} \pm {\bf m}$),
where the sign may be determined as follows:
If ${\bf f} \times {\bf g}$ and ${\bf f} \times {\bf e}$ point in the same direction, then the sign is $+$;
otherwise, the sign is $-$.

One can compose all the steps to get a formula:
$$M = C \pm {||{\bf f} \times {\vec{CD}}|| \over ||{\bf f} \times {\bf e}||}\,{\bf e}\,.$$
If you want to check, we can, in the second example, take $C = (6,8,4)$, $D = (6,8,2)$
and ${\bf e} = (6,7,0)$ and ${\bf f} = (6,7,4)$.  Therefore ${\bf g} = \vec{CD} = (0,0,-2)$.
So ${\bf f} \times {\bf g} = (-14, 12,0)$ and ${\bf f} \times {\bf e} = (-28, 24, 0)$,
which point in the same direction; so we take the $+$ sign.
Therefore the point of intersection is $C + {1\over2}{\bf e} = (9,{23\over2},4)$.
A: The direction numbers $(a,b,c)$ for a line in space may be obtained from two points on the line by subtracting corresponding coordinates. Note that $(a,b,c)$ may be rescaled by multiplying through by any nonzero constant.
The first line has direction numbers $(5,5,2)$ while the second line has direction numbers $(5,5,-2).$ Once one has direction numbers $(a,b,c)$, one can use either given point of the line to obtain the symmetric form of its equation as 
$$\frac{x-x_0}{a}=\frac{y-y_0}{b}=\frac{z-z_0}{c}.$$ Note that if one or two of $a,b,c$ are $0$ the equation for that variable is obtained by setting the top to zero. That doesn't happen in your case.
Using the given point $(5,5,4)$ of the first line gives its symmetric equation as
$$\frac{x-5}{5}=\frac{y-5}{5}=\frac{z-4}{2}.$$
And using the given point $(5,5,5)$ of the second line gives its symmetric form
$$\frac{x-5}{5}=\frac{y-5}{5}=\frac{z-5}{-2}.$$
Now if the point $(x,y,z)$ is on both lines, the equation
$$\frac{z-4}{2}=\frac{z-5}{-2}$$
gives $z=9/2$, so that the common value for the fractions is $(9/2-4)/2=1/4$. This value is then used to find $x$ and $y$. In this example the equations are both of the same form $(t-5)/5=1/4$ with solution $t=25/4$. So we may conclude the intersection point is 
$$(25/4,\ 25/4,\ 9/2).$$
ADDED CASE:
The OP has asked about another case, which illustrates what happens when one of the direction numbers of one of the two lines is $0$. 
Line 1: points $(6,8,4),\ (12,15,4);$ directions $(6,7,0)$, "equation"
$$\frac{x-6}{6}=\frac{y-8}{7}=\frac{z-4}{0},$$
where I put equation in quotes because of the division by zero, and as noted the zero denominator of the last fraction means $z=4$ (so $z$ is constant on line 1).
Line 2: points $(6,8,2),\ (12,15,6);$ directions $(6,7,4)$, equation
$$\frac{x-6}{6}=\frac{y-8}{8}=\frac{z-2}{4}.$$
Now since we know $z=4$ from line 1 equation, we can use $z=4$ in $(z-2)/4$ of line 2 equation, to get the common fraction value of $(4-2)/4=1/2$.
Then from either line, $(x-6)/6=1/2$ so $x=9$, and $(y-8)/7=1/2$ so $y=23/2.$ So for these lines the intersection point is $(9,\ 23/2,\ 4).$
It should be pointed out that two lines in space generally do not intersect, they can be parallel or "skew". This would come out as some contradictory values in the above mechanical procedure.
