Shortest path between two points that makes contact with a line graphed in 3D 
Let l be the line in space through the points $(0, 0, 1)$ and $(1, 1, 1)$. What is
the length of the shortest possible path that begins at the origin, travels to a point on $l$, then ends
at the point $(1, 0, 0)$?

So I've recently encountered this problem about the shortest path between this line and points in a 3D graph. So far, I'm tried to simplify the line into the same plane as the two points (making it just a 2D graph). But so far, I haven't been able to find a way to do that. I've tried shifting the line downwards and moving it one unit along the x-axis, but I just haven't been able to find a way to do it. Does anyone have any ideas?
 A: This is only an overview to the answer. Look at the picture

Suppose $A=(1,0,0)$, $B$ is the middle of $(0,0,1)$ and $(1,1,1)$, and our route is $O\rightarrow P\rightarrow A$. We want to minimize $|OP|+|PA|$.
Point $A’$ is located vertically above $B$ such that $|BA|=|BA’|$. As a consequence, $|PA|=|PA’|$.
The segment $OA'$ intersect $l$ at $Q$.
Now, minimizing $|OP|+|PA|$ is equivalent to minimizing $|OP|+|PA’|$.
Triangle inequality: $|OP|+|PA’|\geq|OA’|$. The shortest route is $O\rightarrow Q\rightarrow A$. I will leave calculating $|OA’|$ to you.
A: Imagine a cube. The origin is pointing towards you. The points $(0, 0, 1)$ and $(1, 1, 1)$ are diagonally across the face furthest from you.
Say the coordinate on $l$ where the two paths meet is $(x, y, 1)$. Then, the distance from there to the origin is $\sqrt{x^2+y^2+1^2}$. The distance from $(1, 0, 0)$ to the point is $\sqrt{(1-x)^2+y^2+1^2}$. We want to minimize the sum of these two radicals, but since they will be positive, it's like minimizing $$x^2+y^2+1+(1-x)^2+y^2+1^2.$$
Expanding and rearranging terms gets $2x^2-2x+2y^2+3$. Since the constant term doesn't matter when minimizing, it suffices to simplify $2x^2-2x+2y^2$, or just $x^2-x+y^2$ by dividing by $2$.
However, the line $l$ is just the line $y = x$ when $z = 1$! Therefore, $y = x$, and so the expression equals $2x^2-x$.
Changing to vertex form we get $2(x-\frac{1}{4})^2-\frac{1}{8}$. So it's minimized when $x = \frac{1}{4}$.
From here, just calculate the distance.
NOTE: I'm not 100% sure on this approach but I believe it is correct. If it's not, please let me know!
