# How do can I use quaternions to find the centroid of a right triangle drawn on a sphere?

I'm modelling a system of rotation using quaternions. Rotations are snapped to 45 degree intervals on any of our axes, X, Y, or Z. I reason that that this would give the system 208 states, corresponding to the normals of an elongated square gyrobicupola (or pseudo-rhombicuboctahedron, if you prefer), and the 8 45-degree rotations about that normal.

An example of the shape used to model my rotations.

I am currently looking at to how to calculate these 208 quaternions using code.

As I understand it:

• no rotation would be $$[0, 0, 0, 1]$$

• Turning 90 degrees in a direction would be some variation on $$[\sqrt{2}, 0, 0, \sqrt{2}]$$

• 45 degrees would be $$[ 0.3826834, 0, 0, 0.9238795 ]$$

• But as for the quaternions corresponding to the normal vector, [1,1,1]... what should that that be?

Reasoning that this point is the centroid of a triangle drawn on the face of a sphere, with axes for its vertices, and learning that a centroid lies 2/3 of the way from a vertex to a side, I typed the my guess into a calculator with axes $$[1,1,1]$$ and an angle of 60 degrees. I got the quaternion $$[ 0.2886751, 0.2886751, 0.2886751, 0.8660254 ]$$ and the matrix:

$$\begin{matrix} 0.6666667 & -0.3333333 & 0.6666667 \\ 0.6666667 & 0.6666667 & -0.3333333 \\ -0.3333333 & 0.6666667 & 0.6666667 \end{matrix}$$

Is this correct? Is my reasoning sound? The matrix "feels" right, with that 2/3 and 1/3 balance going on. And if it is, should I have any problem figuring out the rest by rotations using variations on these values?

Imagine you have a spherical triangle with known vertices. Each vertex has an associated quaternion $$0+xi+yj+zk$$ where $$x,y,z$$ are the cosines of the angles from the positive axes = the Cartesian coordinates of the point, given in terms of spherical coordinates by the usual conversion formulas with $$r=1$$.
For instance, if the triangle vertices are given by $$(1,0,0),(0,1,0),(0,0,1)$$ or in terms of quaternions $$i,j,k$$, the average is $$(i+j+k)/3$$ which has vector magnitude $$\sqrt{1/3}<1$$. Multiply by $$\sqrt3$$ to normalize and your result $$(i+j+k)/\sqrt3$$ properly corresponds to the centroid on the sphere.