# Find a vector from the origin that is a known length and is orthogonal to the plane defined by its endpoint and two other known points?

I have a mechanism that pivot on one point, which I'll call the origin, and is moved by pushing on two other points. These other points are not fixed on the mechanism, but I can compute where they are. The are not in the plane of the pivot, but are on a plane that lies "above" the pivot, and I'm looking for a way to compute where the mechanism is "pointing".

I worked enough geometry problems back when I was in college to believe that there is a solution, so I'm hoping someone who has been doing geometry more recently can help me find it.

My question: Given two points $P_1 = (x_1, y_1, z_1)$, $P_2 = (x_2, y_2, z_2)$ and a distance $d$, find a third point $P_0 = (x_0, y_0, z_0)$ such that it is the given distance $d$ from the origin $O = (0, 0, 0)$ and $\vec{OP_0}$ is normal to the plane defined by $P_0, P_1,$ and $P_2$.

I know the point will be on the sphere of radius $d$. $$x_0^2 + y_0^2 + z_0^2 = d^2$$ Also, I figured that I could use the cross product of the vectors $\vec{P_0P_1}$ and $\vec{P_0P_2}$ to find the normal to the plane, which is some constant $k$ times the vector from the origin $\vec{OP_0}$. $$\vec{P_0P_1}\times\vec{P_0P_2}=k\cdot\vec{OP_0}$$ And finally, I've thought about trying to throw in the equation for a plane. $$ax + by + cz = d$$ But since I don't know the value of the point I'm trying to find ($P_0$), I can't actually solve for $a$, $b$, and $c$, or find the cross product $\vec{P_0P_1}\times\vec{P_0P_2}$.

• Very well-asked question! It might help to note that given $P_1$, the set of points $P_0$ such that $\vec{OP_0}$ is orthogonal to $\vec{P_0P_1}$ is the sphere with diameter $\vec{OP_0}$. – Greg Martin Feb 26 '16 at 8:26
• Thanks Greg. I just followed the suggestions in a previous post on how to ask a good question. I was thinking the equation I gave for a sphere implied the sphere you mention. But you are right that it can be useful to be more explicit. – TruthSeeker Feb 27 '16 at 20:32

Algebraic way: You need a plane $x_0x+y_0y+z_0z-d^2=0$ (because $ax+by+cz=0$ means "$\vec{(x,y,z)}$ is orthogonal to the $\vec{(a,b,c)}$"). Now you have $$\cases{x_0x_1+y_0y_1+z_0z_1=d^2 \\ x_0x_2+y_0y_2+z_0z_2=d^2 \\ x_0^2+y_0^2+z_0^2=d^2}$$ Solving this for $x_0, y_0, z_0$ will give you your $P_0$ (there may be more than one solution or no solutions at all, so algebraic expression for $x_0,y_0,z_0$ will contain numerous cases and will be ugly-looking).
Geometric way: You have a line $(P_1,P_2)$ and a sphere with centre $0$ and radius $d$. You want to build a plane which touches the sphere and contains the line. Let $P'$ be the closest point to $0$ on the line. If $[OP']$ is shorter than $d$, no solution exists. If length of $[OP']$ equals $d$, there is one solution, $P_0=P'$. Otherwise, $\vec{OP_0}$ is orthogonal to $\vec{P_1P_2}$, orthogonal to $\vec{P'P_0}$ and has length $d$, there are two solutions: $$\cases{(x_1-x_2)x_0+(y_1-y_2)y_0+(z_1-z_2)z_0 = 0 \\ (x'-x_0)x_0+(y'-y_0)y_0+(z'-z_0)z_0=0 \\ x_0^2+y_0^2+z_0^2 = d^2}$$ Note there is a special case $d=0$, when $P_0=O$ can be or not be a solution (zero vector is usually considered orthogonal to any vector, but if $P'=O$, these three points won't be defining a single plane).
• These solutions both make sense and it is great to have a couple of ways to look at it. The fact that $a, b, c$ in the plane equation are $x_0, y_0, z_0$ wasn't obvious when I was writing the question, but was when I read the this answer. In the real world mechanism there will always be a solution with the origin on a known side of the plane. – TruthSeeker Feb 27 '16 at 20:46
• These equations both lead to the same "ugly-looking" solution, so I thought of another way of looking at it and found there is a solution for that where the math is worked through. We know the distances between to the known points $|OP_1|$ and $|OP_2|$. We also know $|OP_0|$ and since we have two right triangles $\triangle OP_0P_1$ and $\triangle OP_0P_2$ we also know the distances $|P_0P_1|$ and $|P_0P_2|$. So, with the know points and distances I can use the formulas for Trilateration. – TruthSeeker Feb 27 '16 at 21:24