3

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!

  • Welcome to stackexchange. I think we need more context to help you, since in projective geometry there are no parallel or perpendicular lines. Please [edit] the question to provide that context - perhaps sample input and what you hope to do with output. What does "a line in the form of vectors" mean? – Ethan Bolker Jul 22 '19 at 14:47
  • Thank you for asking for clarification! I've tried to add more context. I'm not sure how to define "parallel" and "perpendicular" exactly, though. Maybe with the other context I added you can see what I mean now? – Eric Simonton Jul 22 '19 at 15:01
  • 1
    @Yves Daoust : the cross product of lines or points makes sense, I would say technically. See Remark 2 in my answer. – Jean Marie Jul 22 '19 at 15:43
  • @Yves Daoust : for example https://math.stackexchange.com/q/1776496 – Jean Marie Jul 22 '19 at 19:11
  • @JeanMarie: yep, my bad, in projective geometry this is absolutely true. Removing my displaced comments. –  Jul 22 '19 at 19:21
  • Strictly speaking, you’re working in what I would call the “extended Euclidean plane” because “parallel” and “perpendicular” are not projective-geometric concepts. – amd Jul 22 '19 at 23:09

3 Answers3

4

[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.

amd
  • 53,693
  • [+1] Very interesting and well written. In fact, I thought afterwards that orthogonality could be introduced in the framework of projective geometry through Laguerre's formula (https://en.wikipedia.org/wiki/Laguerre_formula). A detail : you haven't referenced the appropriate answer. – Jean Marie Jul 23 '19 at 06:27
  • @JeanMarie Oops! Fixed the reference. – amd Jul 23 '19 at 07:18
  • 1
    @JeanMarie One way to impose a Euclidean geometry on the real projective plane is to choose a pair of (perhaps complex conjugate) points as the “circular points” $\mathbf I$ and $\mathbf J$ that are fixed under similarities. The bilinear form defined by the matrix $C_\infty^* = \mathbf I\mathbf J^T+\mathbf J\mathbf I^T$ is the corresponding inner product. The resulting expression for $\cos\theta$ is projectively invariant, and is equivalent to Laguerre’s formula. – amd Jul 23 '19 at 07:41
  • Very interesting, once again. – Jean Marie Jul 23 '19 at 08:30
  • This actually makes some intuitive sense to me now, thanks! And bonus points for showing me how to do it with the dot product - that's what I'll actually use in my code. – Eric Simonton Jul 23 '19 at 13:09
  • @EricSimonton It’s a bit more efficient to code the formula directly, I think, since quite a few of the multiplications and additions in those cross products don’t really do anything other than eventually copying a value to the output. – amd Jul 23 '19 at 18:29
2

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.

Jean Marie
  • 81,803
  • This is fantastic, thank you so much! I sadly will not get to actually try this in my code until tomorrow, but will definitely come back and accept your answer once I see it work (which I'm sure it will). – Eric Simonton Jul 22 '19 at 15:51
  • It is strange to have been downvoted for an exact answer... – Jean Marie Jul 22 '19 at 19:08
  • I’m not sure that I entirely agree with the last part of this answer. One can get the point at infinity that corresponds to the line’s normal by setting its last coordinate to zero. The perpendicular to the line through some point can then be constructed with a cross product, and similarly for a parallel line through some point. – amd Jul 22 '19 at 23:14
0

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.$$