# making three parallel lines (3d) with equal distance seperation

I have three parallel lines (3d lines). say AB, CD, EF. The center line i.e. CD is given by intersecting the two planes by which the AB, DE lie on. The shortest distance between AB and CD (say d1) is not exactly equal to the CD and EF (say d2).

the line which is given a shorter distance from the center line should be replaced by a fourth line, making equal distance separation with the other line.

I know vectors of each line, and also know a 3D point lie on each line as well.

I was trying to do it. But cannot figure out exactly and got some wrong answers. sometime fourth line make the separation more shorter (may be the vector is directing other way). I should say that vectors of AB,CD & EF lines are not directing in to same direction.

So, I am looking for a concrete way to do this. I have vector3 class.

please anyone show me how to do this. thanks

-
Also posted as stackoverflow.com/q/13612752/1468366 –  MvG Nov 29 '12 at 7:39

I know vectors of each line, and also know a 3D point lie on each line as well.

So I assume you have the points $A$, $C$ and $E$ as well as the vectors $(B-A)$, $(D-C)$ and $(F-E)$ (which all point into the same direction). Furthermore I assume that there is no special relation between your points, and that in particular you have no guarantee that the points $ABC$ span a plane which is perpendicular to all of your parallel lines.

First I'd obtain two vectors which point from $CD$ into the direction of the other two lines. You can obtain them like this:

\begin{align*} v &= (A-C) - \frac{(A-C)\cdot (D-C)}{(D-C)\cdot (D-C)}(D-C) \\ w &= (E-C) - \frac{(E-C)\cdot (D-C)}{(D-C)\cdot (D-C)}(D-C) \end{align*}

What this does is take the difference vector $(A-C)$ reso. $(E-C)$ and subtract from that the component in the direction of line $CD$. The result will be a vector pointing from $CD$ to $AB$ resp. $EF$ which is orthogonal to $CD$.

Now you can use $\lVert v\rVert$ and $\lVert w\rVert$ to compare distances. Let us for the moment assume that $\lVert v\rVert < \lVert w\rVert$. In that case, you want to compute $A' = C + \frac{\lVert w\rVert}{\lVert v\rVert}v$ and $B'=A'+(B-A)$. Otherwise you compute $E'$ and $F'$ in a similar way.

-
if I ask like this, as my A,B,C,D and C,D,F,E points lie on 2 planes, if I compute the perpendicular vectors which are orthogonal to center line (say v, w) using cross product of plane normal and direction vectors of line AB & CD, then how would be the rest. bcz it would also like to know as it would be easy for me as i implemeted some of them. In here, I should say AB and EF are not directing into same direction, but both plane normals are directing upwards. if you could, please add this solutions as well. (plz keep ur previous answer. need to study the way). thanks –  gnp Nov 29 '12 at 9:04
in my case, length of the lines are not equal and A, C, E and B,D,F not linear as well. thanks –  gnp Nov 29 '12 at 9:07
If you have the normal of the plane $ABCD$, and the direction $(D-C)$, then their cross product $v'$ points in the same direction as my $v$, but to actually get the correct length you'd have to adjust the length to $v=\frac{v'\cdot (A-C)}{v'\cdot v'}v'$. If $AB$ and $EF$ are not pointing in the same direction, then your lines are not parallel! Your comment about “lengths of the lines” sounds like you are referring to line segments, not infinite lines. Does “$A,C,E$ [are] not linear” mean they are not collinear? That's fine, I expected that. –  MvG Nov 29 '12 at 9:37
yes, at the meantime i found another points for each line. No, I mean my lines AB, CD, EF are parallel but not pointing to the same direction. i.e. 180 degree opposite direction. Also I comuted the 2D distance between AB-CD and EF-CD. So, I want to keep these distances equal by shifting the AB or EF. But I am getting wrong answer bcz AB and EF are 180 degree opposit though plane normals are always upward. anyhelp to rectify this please. thanks –  gnp Nov 29 '12 at 9:51
In the sense of my answer, opposite directions serve as “same direction”. What I actually meant was that one vector is a multiple of the other, where the coefficient might as well be negative. As my solution does not use plane normals, it should work for you. –  MvG Nov 29 '12 at 9:57