# Calculate sphere radius using two vector points.

Using accelerometers I have acquired two $3D$ vectors $V_1$, $V_2$ which both have $(x, y, z)$.

Assume that these vectors are points ($P_1$ and $P_2$) on the surface of a sphere ($S$), so that the vector is perpendicular to the surface. Also assume that $P_1$ and $P_2$ are on the same hemisphere of the surface. The distance between $P_1$ and $P_2$ is static: $d=0.2m$.

How do I calculate the radius/diameter of the sphere?

In context: two accelerometers provide the data for $V_1$ and $V_2$. They are positioned on the chest ($P_1$ and $P_2$), the chest is the sphere, the distance between the accelerometers ($d=0.2m$) is static and breathing causes the accelerometers to 'rotate' (and thus changing the vectors).

• What do you mean by "a point is perpendicular to the surface of the sphere"?
– mfl
Feb 1 '16 at 18:10
• The point, well.... actually it is a vector is positioned on the surface of the sphere. Because I do know the static absolute distance between the vector(points), it should be possible to calculate the sphere itself (and thus the radius). Feb 1 '16 at 18:20

TL;DR $r = \frac{d}{\sqrt{2(1-\cos\theta)}}$ where $\theta$ is the angle between the two vectors

If I got your problem right, here is how you do it.

You have: two vectors $V_1,V_2$ perpendicular to the surface of the sphere, and the distance $d$ between the two points at the bases of the vectors. You want to calculate the radius $r$ of the sphere.

Imagine the two points lying on a circle in the $xy$-plane (a section of the sphere) with the origin at the centre of the circle, an place one of the two points on the $x$-axis.

With a little trigonometry, you will see that $d$ is the hypothenuse of a triangle with sides $r\sin\theta$ and $r-r\cos\theta$, where $\theta$ is the angle between the lines connecting the two points with the origin. A little algebra yields the result.

You can calculate the cosine using the vectors and the formula for the dot product: $V_1 . V_2= |V_1| | V_2|\cos\theta$.

• Thank you very much Andrea! That did the trick. $r = \frac{d}{\sqrt{2(1-\frac{V_1 . V_2}{|V_1| | V_2|})}}$ I'm happy to say that this method provides an even better signal than the simpel method I used before! Feb 3 '16 at 13:06