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:
- The line parallel to l that goes through p
- 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!
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) :
meaning that the cartesian equation of $L'$ is $ax+by-(aA+bB)=0$.
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.