# How to describe a position of a point w.r.t the position and orientation of 3 other points

Is it possible to describe a position of a point $A$ (in 3D) w.r.t. the position and orientation of 3 other points? If so, how?

FYI, the 3 other points lie on a plane, whereas the point $A$ is not on the plane.

Just to elaborate, initially I have the info for all four points. My goal is to find where point $A$ is when the other three points changing position and orientation.

• Yes, 3 points in any dimension above 2 all lie on the same plane unless they are degenerate and lie on a line – joojaa Jul 5 '17 at 10:04
• Or even an infinite number of lines for the most degenerate case. (I'll show myself out) – Simon F Jul 5 '17 at 10:50
• @SimonF and planes ;) – joojaa Jul 5 '17 at 11:00

## 2 Answers

FYI, the 3 other points lie on a plane

Of course they do. Any set of three points defines a plane (except in the degenerate case joojaa mentions, where they lie on many planes). If the points are $p$, $q$, and $r$, then $(q - p) \wedge (r - p)$ is the normal to the plane; call it $n$.

This plane defines a co-ordinate system. If you make it the XY plane, then $z = a \dot\ n$. You can also project $a$ onto the plane to get the other two co-ordinates: $x = (a - p) \dot\ (q - p)$ and $y = (a - p) \dot\ (r - p)$.

Note that the co-ordinate system I've described here is pretty rubbish: it isn't even orthogonal. It's good enough to uniquely identify a point, as long as you're careful about all the signs.

But if you want an orthonormal basis, you can construct it from this one. First, instead of $q - p$ and $r - p$, normalize those vectors. Then $n$ will also have length 1, and the $x$ axis will also be normal. The last problem is the $y$ axis, which is not orthogonal to the $x$ axis. You can get a better $y$ axis by crossing the other two and normalizing, and while you're doing that you might as well also choose the order to ensure the basis is right-handed. Your three basis vectors are as follows:

$$\begin{eqnarray} \hat{z} & = & \frac{n}{|n|} \\ \hat{x} & = & \frac{q - p}{|q - p|} \\ \hat{y} & = & \hat{z} \wedge \hat{x} \end{eqnarray}$$

• Please check my maths, people. I haven't done this since I was an undergrad. :-) – Dan Hulme Jul 5 '17 at 10:33
• Well yes i would just construct a affine matrix with a crossed and normalized 3 axis does much the same but with less thinking, and then just matrix multiply. Anyway your missing one normalize. – joojaa Jul 5 '17 at 10:37
• Yeah, doing it by a matrix would have been simpler but maybe harder to understand. Thinking about each vector separately lets you approach the problem a piece at a time instead of all at once. – Dan Hulme Jul 5 '17 at 10:44
• I would say its easier to understand as it has a more straightforward visual interpretation. Assuming you know how affine matrices work – joojaa Jul 5 '17 at 10:57
• $a$ is the point? I haven't fully understand it. So, what's next after I know the three basis vectors? – Bla... Jul 5 '17 at 11:20

What you're looking for is closest point on a plane for the 3rd direction but since @DanHulme described this I would not repeat it.

You can pretty easily use affine transformation matrices for this. Making a fully defined affine transform from 3 points is a pretty normal operation.

The standard way is to just use a cross product to produce a third axis (possibly normalized, but whether or not you want to do that depends on application) this way you have 2 axes on the plane and one perpendicular to the plane.

To form the matrix say you have the vectors $\vec a$, $\vec b$ and $\vec c$ then you formulate the matrix. Then you calculate the vector from a to b $\vec v_{b-a}$ by subtracting $\vec a$ from $\vec b$, and a second vector $\vec v_{c-a}$ by subtracting $\vec a$ from $\vec c$. So basically 2 spanning vectors pointing out from $\vec a$. Then you formulate this as a matrix.

\begin{bmatrix} \vec v_{b-a} \\ \vec v_{c-a} \\ \left|\vec v_{b-a} \times \vec v_{c-a}\right|\\ \vec a \end{bmatrix}

Thats about it. Some more maths to orthogonalize the thing.

• Then, how do you get the point A? – Bla... Jul 5 '17 at 11:14
• Just to elaborate, initially I have the info for all four points. My goal is to find where point $A$ is when the other three points changing position and orientation. – Bla... Jul 5 '17 at 11:23
• Ah I think I understand your point. – Bla... Jul 5 '17 at 11:40