I am given eight coordinate points in xyz plane, how can I verify that they form a cube?
Thanks,
I am given eight coordinate points in xyz plane, how can I verify that they form a cube?
Thanks,
In computer graphics one can find some amazing, non-trivial and very efficient tests (see chapter $16$ of the Real-Time Rendering book, for what I mean by this).
I do not claim to have such a solution.
What you could do is to test for certain properties of a cube.
The general idea is to come up with a list of properties that fully characterize a cube, i.e. if all are fulfilled it can only be a cube. If at least one property is not fulfilled, it can not be a cube.
For efficiency one should sort the list of properties such that the most discriminating ones are tested first.
You can check with vectors. Suppose you are at a corner of the cube and you have these 3 vectors popping out of the corner corresponding to the 3 edges:
$\vec a=\begin{pmatrix}x_1\\y_1\\ z_1\end{pmatrix}, \vec b=\begin{pmatrix}x_2\\y_2\\ z_2\end{pmatrix},\vec c=\begin{pmatrix}x_3\\y_3\\ z_3\end{pmatrix}$
You want the vectors to have the same length so : $|\vec a|=|\vec b|=|\vec c|$
$|\vec a|= \sqrt{x^2+y^2+z^2} $
So, check if they have the same length.
Afterwards you need to show that the vectorial product $ \vec a \times \vec b $ is parallel to vector $\vec c$. You can calculate the vectorial product using determinants. To check if $ \vec a \times \vec b $ is parallel to $\vec c$ check if their coordinates are proportional.This would mean that $ \space \space \vec c$ is perpendicular to the plane set by vectors $\vec a, \vec b $.
Finally you need to show that the angle betwenn $\vec a$ and $ \vec b$ is 90 degrees.
$ |\vec a \times \vec b|= |\vec a| \cdot |\vec b| \cdot sin \theta$ , $\theta$ being the angle between vectors $ \vec a $ and $ \vec b$. So, $ sin\theta = \frac{|\vec a \times \vec b|}{|\vec a| \cdot |\vec b|}$ Use your solution from the previous step to find $|\vec a| \cdot |\vec b|$. You should have $sin \theta = 1$