Parallel and perpendicular line through a point

982 Views Asked by At

I inherited some code that deals with what I now know are homogeneous coordinates in projective geometry (probably not exactly the right terms, but hopefully close enough that you know what I mean). It takes as input points in 2D space, converts them to homogeneous coordinates in 3D space to do some calculations, then back to returns its results.

I have learned that given two lines, their cross product gives me the point at which they intersect. Similarly the cross product of two points gives me a line that goes through them. I inherited all that, and now I understand it.

But now to cover some edge cases, I need to know how to do something new. Given a line l and a point p, I want to be able to calculate:

  1. The line parallel to l that goes through p
  2. The line perpendicular to l that goes through p

I am a software developer, not a mathematician. This is far outside my normal experience. I have searched and searched, but cannot come up with it on my own. Any help would be appreciated!

3

There are 3 best solutions below

3
On BEST ANSWER

Consider the cartesian equation of given line $L$ under the following form

$$ax+by+c=0$$

$(a,b,c)$ is a vector characterizing line $L$ (up to a factor).

Let $(A,B)$ be the coordinates of a certain point $P$.

Here are the results (explanations below) :

  • The parallel line $L'$ to $L$ passing through $P$ is characterized by vector

$$(a,b,-(aA+bB)),$$

meaning that the cartesian equation of $L'$ is $ax+by-(aA+bB)=0$.

  • The perpendicular line $L''$ to $L$ passing through $P$ is characterized by vector

$$(b,-a,-(bA-aB)),$$

meaning that the cartesian equation of $L''$ is $bx-ay-(bA-aB)=0$.

Explanations :

  • Replacing $(x,y)$ by $(A,B)$ makes $0$ in both equations, proving that both lines pass through point $P$.

  • The normal vector $(a,b)$ is preserved for $L'$ and transformed into an orthogonal one $(b,-a)$ for $L''$.

Remarks :

1) "up to a factor" could be called a projective geometry setting ; @Ethan Bolker says it is abusive to speak of orthogonality in this framework. But see remark 3.

2) If point $(A,B)$ is rendered in the projective setting by homogeneous coordinates $(A,B,1)$ (up to a factor), it is true that the cross product of the homogeneous coordinates $(A_1,B_1,1)$ of point $P_1$ with point $P_2$ with homogeneous coordinates $(A_2,B_2,1)$ gives the coordinate vector of line $P_1P_2$, and that the intersection point $P$ of lines $L_1$ and $L_2$ with resp. associated vectors $(a_1,b_1,c_1)$ and $(a_2,b_2,c_2)$ has coordinates given (up to a factor) by cross product $(a_1,b_1,c_1) \times (a_2,b_2,c_2)$ . Do you need it here ? I am not sure.

Edit : In fact I have modified remarks 1) and 2) whose initial form have triggered a very interesting answer (see below) by @amd.

0
On

Assuming that you have the implicit equation of the line,

$$ax+by+c=0,$$

the parallel by $(x_p,y_p)$ is

$$ax+by=ax_p+by_p$$ and the perpendicular

$$bx-ay=bx_p-ay_p.$$

6
On

[This is intended as a supplement to Jean Marie’s answer.]

To review, the equation $ax+by+c=0$ of a line can be written as the dot product $(a,b,c)\cdot(x,y,1)=0$, so the vector $(a,b,c)$ can be used to represent the line. Multiplying both sides of an equation by a nonzero scalar doesn’t change its solution set, so any nonzero multiple of $(a,b,c)$ represents the same line, and similarly, if $(x,y,1)$ satisfies the equation, then so does $(kx,ky,k)^T$, so both of the coordinate vectors in these equations are homogeneous. I’ll denote them with colons instead of commas to emphasize this.

Every family of parallel lines has a unique point “at infinity” that is the intersection of all of the lines in the family and vice-versa: every point at infinity has a corresponding distinct family of parallel lines that pass through the point. Thus, each point at infinity represents a unique direction on the plane.

The homogeneous coordinates of a point at infinity have the form $(x:y:0)$. Just as you convert the Cartesian coordinates of a finite point to homogeneous coordinates by appending a $1$, you convert the Cartesian coordinates of a direction vector by appending a $0$.

Given the line $(a:b:c)$, it should be fairly obvious that its point at infinity is $(b:-a:0)$. So, if you want the line parallel to this one that passes through the point $(A:B:1)$, you can compute their cross product just as you might do with two finite points: $$(A:B:1)\times(b:-a:0) = \left(a:b:-(aA+bB)\right).$$ In the same vein, two direction vectors are perpendicular iff their dot product vanishes, and this carries over to the corresponding points at infinity†. It should be fairly obvious that $(a,b)$ and $(b,-a)$ are perpendicular, thus to obtain the line through the point $(A:B:1)$ that is perpendicular to $(a:b:c)$, you can again use a cross product: $$(A:B:1)\times(a:b:0) = (-b:a:bA-aB).$$ Since nonzero multiples of the homogeneous coordinates of an object are equivalent, this formula produces the same line as the one in the other answer.


† Strictly speaking, we need to use the scalar product associated with the Euclidean geometry that we’ve imposed on the projective plane, but for the coordinate system that we’re using here, it’s just the dot product of the homogeneous vectors with their last component set to zero.