# How to scale a polyhedron contained a 3-sphere?

In the 3-sphere simulator I am building, the viewpoint is contained in the space of a 3-sphere (the surface of a 4-D hypersphere), and the user is able to navigate through it.

There are some polyhedra floating in this space. They are represented as connected 4-D euclidean points, every point $P$ so that $|P| = 1$, what keeps the shape contained in the 3-sphere of radius $1$.

I am able to rotate and move those objects around by using $4\times4$ rotation matrices, that also ensure that the objects are kept in the space. (See the relevant question here).

Now I am in the point that I need to scale the objects. I know I can't simply use a 4x4 scale matrix, because that would take the points off of the 3-sphere. I need some way (that is not too computationally intensive) to scale the object linearly to the great-circle distance between the polyhedron point and its origin.

So I have the polyhedron point $P$ and the origin $O = (0, 0, 0, -1)$, both 4-D euclidean points. Then I need $P'$ so that: \begin{align} &P' = SphereScale(P, factor) \\ &CircleDistance(P, O) = factor \times CircleDistance(P', O) \end{align}

The radius of the 3-sphere is always 1.

I do not know what it is this $SphereScale$ function, nor I am sure how to calculate this $CircleDistance$. I am aware that after certain size, the polyhedron starts to shrink to the other opposite half of the 3-sphere, so to collapse in the symmetric opposite point of its origin – that should be $(0, 0, 0, 1)$. What can you tell me about that $SphereScale$ function or the whole effect I want to obtain?

Sorry if I could not express myself very clearly. I am more of a programmer than a mathematician.

-

I think what you want is the procedure known in the graphics community as spherical linear interpolation, or Slerp for short. The parameter $t$ there is your scale factor; despite the condition $0 \le t \le 1$ in the article, I expect it should still do the right thing if you set $t > 1$.

Here is the explanation as promised. What you want to do is, given two unit vectors $O$ and $P$ that differ by an angle $\theta$, and a scale factor $t$, to find a unit vector $P'$ whose angle with $O$ is $t\theta$. You implicitly also want $P'$ to lie in the same two-dimensional subspace as $O$ and $P$, and oriented the same way as $P$ relative to $O$.

As it turns out, this is exactly what Slerp does. To be precise, $$P' = \operatorname{Slerp}(O,P; t) = \frac{\sin((1-t)\theta)}{\sin\theta} O + \frac{\sin(t\theta)}{\sin\theta}P.$$ Clearly, when $t = 0$, the point shrinks to $O$; when $t = 1$, you get back the point $P$. Bigger $t$ will send your point farther from $O$, until you get to $t\theta = \pi$, where you find that $P' = -O$.

One way you could derive this is to find an orthogonal basis $\{O,Q\}$ for the subspace spanned by $O$ and $P$. Then you have $P = O\cos\theta + Q\sin\theta$, and the point you want is $P' = O \cos t\theta + Q \sin t\theta$. Substituting $Q$ in terms of $O$ and $P$ should get you back to the Slerp formula.

The nice thing about all this is that since we're only concerned with unit vectors in a two-dimensional subspace, it's essentially just a problem of finding points at specified angles on a circle. However, I should also point out that unlike scaling in Euclidean geometry, where it doesn't matter (up to translation) what point you scale with respect to, on a sphere it does matter, and it will change the shape of your polyhedron. So, if your polyhedron is "regular" in some sense, make sure you scale with respect to the center of the polyhedron to preserve its regularity.

-
Someone said the same thing about navigating through the 3-sphere, but I don't see how slerp can help me... – lvella Jan 15 '12 at 16:50
@lvella, please see my edit. – Rahul Jan 16 '12 at 6:58
Ok, I didn't believe at first this would do, but now I believe. Let me code it... – lvella Feb 7 '12 at 12:45
@lvella, just checking: did it work for you? – Rahul Mar 3 '12 at 23:27
Yes. Actually I did not use the full solution, but a simpler variation inspired by the orthogonal basis thing. The polyhedra I was drawing were sphere representations (an icosphere and an uv-sphere), thus I had $O = (0,0,0,-1)$ and $Q = (x,y,z,0)$, where $(x,y,z)$ is on the surface of the radius $1$ sphere I was drawing. When I figured O and Q were naturally orthogonal, I had my basis and just needed to variate $\theta$. – lvella Mar 4 '12 at 15:16