# Equation to a Perpendicular Line Along A Plane

I have the following problem, which Google has not yet been able to answer.

I have the equations to two lines in 3D space. I also have the co-ordinates of a single point on each line. I can therefore find the co-ordinates of a third point on either line and compute the equation to a plane that contains both lines.

Now what I need to do is to compute the equation to the normal lines to each of these lines so that both normal lines are also on this plane. After this, I need to find the point of intersection of these two lines.

I'd appreciate any help on this topic.

Thank you.

PS: This is my first post on MSE, so if I'm violating any MSE rules, please point them out so that I can correct my post and not make such a mistake in the future

I'm not trying to solve a specific question. I'm trying to write a program that is flexible enough to do this.

So as parameters to this program, I have values for A, B, C - the coefficients for the equations to the lines written as Ax + By + C = z.

I know that for every pair of lines, there is a plane on which these two lines reside. I will therefore need to compute the equation to this plane.

The idea is that there is an object moving along a path (some curve) on a plane (some plane whose equation I must compute), that I detect with a sensor. I am allowed to assume a monotonous curve between any two consecutive detections. I need to figure out the coordinates of the center of the circle on whose circumference this monotonous curve exists.

Please let me know if that clarifies the question

-
Do you know that the two lines are in a plane? sometimes two lines are NOT in the same plane... How are the lines given to you? – N. S. Nov 17 '11 at 22:48
You'd better give more details for your problem. I get it that you want to solve it, but you don't know how. Present us the two equations of the lines and the full question you are looking to solve so that we can help you. In this state, your question is a bit confusing. – Beni Bogosel Nov 17 '11 at 22:57
You aren't violating any rules, but we do have a custom here that questions are supposed to make sense. If all you know about two lines in 3-space is that one of them goes through $(1,0,0)$ and the other goes through $(0,0,1)$ then you can't find a third point (or even a second point) on either line and you can't compute an equation for a plane containing both lines - and that's even if you know somehow that there is such a plane. Please rethink your question and edit it into something sensible. – Gerry Myerson Nov 17 '11 at 23:00
$Ax + By + Cz + D = 0$ is the equation of a plane, not a line (three unknowns, one constraint, so essentially two-dimensional). In three dimensions, two straight lines usually do not lie on a single plane (if they do not intersect and are not parallel). – Henry Nov 17 '11 at 23:34
@inspectorG4dget The equation you have up there: $Ax+By+C=z$ is still the equation of a plane. Rule of thumb: 1 equation generically knocks out 1 dimension. So a line (1 dimensional) in $\mathbb{R}^3$ needs to be specified by 2 equations ($3-2=1$). Also, what you are trying to do is not possible in general. For 2 lines to lie in a common plane they need to be either parallel or intersecting. For lines in $\mathbb{R}^2$ this is always the case. However, for lines in $\mathbb{R}^3$ there is a third possibility. They can be skew. – Bill Cook Nov 18 '11 at 0:42

I will give a solution whose starting point is as follows: I know two points $P_1$ and $P_2$ on line 1 and points $Q_1$ and $Q_2$ on line 2.

Form the vectors ${\bf p} = P_2-P_1$ and ${\bf q}=Q_2-Q_1$.

Check for an intersection of the two lines: ${\bf p}t+P_1={\bf q}s+Q_1$ for some pair of real numbers $s$ and $t$. If no solution is found, the lines do not intersect.

Next, check to see if ${\bf p}$ is a scalar multiple of ${\bf q}$ (i.e. ${\bf p}=s{\bf q}$ for some $s$). If this is true, the directions of the lines are parallel.

There are 4 cases:

1) Intersecting + Parallel Directions = They are the same line (FAIL: One line will not determine a plane.)

2) Not Intersecting + Non-parallel Directions = They are skew lines (FAIL: Skew lines do not lie in a common plane.)

3) Not Intersecting + Parallel Directions = Parallel lines. In this case any normal line for one line will be normal for the other. So any point in the plane will lie on a common normal line. If you would like a point "between" the two parallel lines: Form a vector ${\bf r}=Q_1-P_1$ (this points from $P_1$ on line 1 to $Q_1$ on line 2). Project this vector ${\bf r}$ onto ${\bf p}$ (the direction of the first line): ${\bf w}=\mathrm{proj}_{\bf p}({\bf r}) = \frac{{\bf p\cdot r}}{|{\bf p}|^2}{\bf p}$. Then ${\bf r}-{\bf w}$ is a vector which lies in the plane and is orthogonal to the first line and points from the first line to the second. So $P_1+(1/2)({\bf r}-{\bf w})$ is a point exactly half-way between the two lines.

4) Intersecting + Non-parallel Directions = Distinct intersecting lines. In this case compute the cross product ${\bf n}={\bf p} \times {\bf q}$ to get a vector normal to the plane. Then ${\bf v} = {\bf n} \times {\bf p}$ will lie on the plane and be perpendicular to line 1. Likewise ${\bf w}= {\bf n} \times {\bf q}$ for line 2. Then the lines parametrized by ${\bf v}t+P_1$ and ${\bf w}s+Q_1$ will be normal to lines 1 and 2 respectively. Solving ${\bf v}t+P_1={\bf w}s+Q_1$ will give you the point of intersection of these normals.

Edit: Oops! I forgot to mention. If the lines intersect and you create normal lines at that point of intersection, then those normal lines intersect at that point of intersection!

-
Very exhaustive! – J. M. Nov 18 '11 at 1:13