given eight vertices, how to verify they form a cube? I am given eight coordinate points in xyz plane, how can I verify that they form a cube?
Thanks,
 A: 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.
 (Source)
 (Large Version)


*

*only certain distances should show up if you calculate the symmetric matrix of distances
$$
d_{ij} = \lVert u_i - u_j \rVert
$$
where $u_i = (x_i, y_i, z_i)^T$, like base length $a$, face diagonal length $\sqrt{2} \, a$, volume diagonal length $\sqrt{3} \, a$. For faster calculation, one might stick with the squared distances $d_{ij}^2 = \lVert u_i - u_j \rVert^2$ and check for the occurrence of $0$, $a^2$, $2 a^2$ and $3 a^2$ entries only, in the proper amounts (see below). 

*the smallest non-zero distance should give the base length $a$

*there should be $8$ distinct vertices $u_i$ (only the diagonal entries $d_{ii}$ should be zero)

*of the $(8\cdot 8 - 8)/2 = 28$ distinct segments $(u_i, u_j)$ with $i < j$, $s_{ij} = u_i - u_j$ there should be


*

*$12$ distinct segments of base length $a$

*$6\cdot 2 = 12$ distinct face diagonals

*$4$ distinct volume diagonals


*the $i$-th row of $d_{ij}$ should contain


*

*one zero at $d_{ii}$

*three base length entries

*three face diagonal entries

*one volume diagonal entry


*the same counts should occur for the $i$-th column

*relative angles between segments


*

*line segments of base length $a$ should have relative angles of $0^\circ$, $\pm 90^\circ$, $180^\circ$ only, or $\cos \varphi = (s_{ij} \cdot s_{kl})/ a^2 \in \{ 0, \pm 1 \}$

*face diagonals have relative angles of $0^\circ$, $\pm 90^\circ$, $180^\circ$, $\pm 60^\circ$

*volume diagonals have relative angles $\cos \varphi = \pm (1/3)$



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.
A: 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$
