# Closest point on Affine Line to Origin?

I have had two courses of linear algebra and was always aware that affine spaces were a thing. What I know about affine spaces are that they are similar to vector spaces but do not necessarily have to go through the euclidean origin. Aside from this I only know the the difference of two vectors (displacement vector) in the affine space will be a point / position vector on the associated linear space that goes through the origin. Thats where my knowledge ends.

I was playing around today with the affine line

$$\vec{r}(t) = \begin{pmatrix}1\\-3\\4 \end{pmatrix} + t \, \begin{pmatrix}1\\2\\1 \end{pmatrix},$$

and its associated linear line

$$\vec{r_{1}}(t) = t \, \begin{pmatrix}1\\2\\1 \end{pmatrix}.$$

I wanted to

find the closest point on the affine line $\vec{r}(t)$ to the actual orgin in $\mathbb{R}^{3}$

because it didn't seem like it should be too hard, but I am failing. Any advice?

For visualization I was plotting these objects and verifying the difference of vectors / parallelogram rule.

Its probably pretty unclear whats going on in this photo, I should have labeled things. I'll work on adding some labels right now.

Also this problem can probably be solved without the notions of affine spaces but I guess I was trying to do this task as a way to slowly learn / get oriented with affine spaces.. so I will gladly accept answers and comments with or without talk of affine spaces.

• Well, I just found the plane thats perp to both of them. I didnt even think to use the null space of the direction of both lines. Now I just have to find the intersection of the planes with both lines I believe. – Prince M May 8 '16 at 1:46
• Have a look at this en.wikipedia.org/wiki/… – jazzinsilhouette May 8 '16 at 1:50
• If you just want to figure out the closest point on $r$ to $(0,0,0)$, then you're basically searching for a $t \in \mathbb{R}$, such that $\|v_{t}\|$ is minimized. Here $v_t$ is a specific point on $r$. One way to find such a $t$ is by calculating the (euclidean) norm of $v_t$. This will give you a quadratic function, which has a unique minimum. – jazzinsilhouette May 8 '16 at 2:08
• As far as working with affine spaces as such, the only ways I've seen them dealt with are via linear algebra, synthetic geometry, or as a context for algebraic geometry. The first, because you can rig an affine space to behave like a vector space. The second, because sometimes you don't care about lengths. The third, because (in general) polynomials are indifferent to the location of the origin. I don't think people use affine spaces for their structure as much as to specify which features of the space are (un)important for a particular context, or because they arise naturally. – J. David Taylor May 8 '16 at 2:30

To find the point, we are going to subtract off the part of $p=[1,-3,4]^t$ that is parallel to the affine line. The resulting vector will point straight from the origin to the affine line at a right angle to the line.
The affine line is parallel to $v=[1,2,1]^t$, so we normalize this to a unit vector $u=\frac{1}{\sqrt{6}}[1,2,1]^t$. If we take the dot product of this unit vector with $p$, then we will get magnitude of the component of $p$ parallel to the affine line. The dot product is $p\cdot u = \frac{1}{\sqrt{6}}(1-6+4)=\frac{-1}{\sqrt{6}}$. Thus the component of $p$ in the $v$-direction is $(p\cdot u)u=\frac{-1}{6}[1,2,1]^t$. Subtracting this off from $p$ yields $$p- (p\cdot u)u=[1,-3,4]^t-\frac{-1}{6}[1,2,1]^t=\frac{1}{6}[7,-16,25]^t.$$ Call this point $q$, and note that it has length $\frac{\sqrt{930}}{6}\approx5.08$.
Now we must show that any other point on the line is at least that far away from the origin. $$\lVert[t+1,2t-3,t+4]^t\rVert^2 =(t+1)^2+(2t-3)^2+(t+4)^2\\ = t^2+2t+1+4t^2-12t+9+t^2+8t+16\\ =6t^2-2t+26$$ has vertex at $t=\frac{1}{6}$ with value $\frac{155}{6}=\left(\frac{\sqrt{930}}{6}\right)^2$. So $\frac{\sqrt{930}}{6}$ is the smallest distance from a point on the affine line to the origin, and we have a point on the affine line that is precisely that distance.