Creating a “Swiss Torus” using

general-topologygeometryMATLAB

I have the following matlab code that generates a "Swiss Roll":

%% create swiss roll data
N = 2^11; % number of points considered
t = rand(1,N);
t = sort(4*pi*sqrt(t))'; 

%t = sort(generateRVFromRand(2^11,@(x)1/32/pi^2*x,@(x)4*pi*sqrt(x)))';
z = 8*pi*rand(N,1); % random heights
x = (t+.1).*cos(t);
y = (t+.1).*sin(t);
data = [x,y,z]; % data of interest is in the form of a n-by-3 matrix

I understand how this works. It takes a bounded parameterized curve on the $x-y$ plane and then samples a bunch of other random points above this curve to generate a ''3-D" Swiss roll, which ends up looking like this:

enter image description here

and more specifically the image on the right since it graphs a bunch of colorized points, not a plane. My question is how would I go about ''gluing both ends together" in matlab/in general? I essentially want to create a ''Swiss Torus", if that makes sense. In order to achieve this, I know I need to alter $x,y$ and $z$ in the paramaterizaton, but I am not sure exactly how. I am aware of the equations used to generate a torus, but I am having trouble turning the Swiss Roll into a torus without damaging the integrity of the data (as in maintaining the ''roll"). Could anyone guide me in the right direction?

Best Answer

A regular torus is a special case of a surface of revolution. The "swiss torus" you want to build is also a special case of a surface of revolution. Since your curve $$ C(v) = \begin{pmatrix} x(v) \\ y(v) \\ z(v) \end{pmatrix} = \begin{pmatrix} (v+0.1)\cos v + x_0 \\ (v+0.1)\sin v \\ 0 \end{pmatrix} $$ is given in the $xy$ plane, you want to rotate it about the $y$ axis. I added a translation $x_0\gt 0$ so that the surface of revolution does not self-intersect. The following matrix rotates by an angle of $u$ about the positive $y$ axis: $$ R(u) = \begin{pmatrix} \cos u & 0 & \sin u\\ 0 & 1 & 0 \\ -\sin u & 0 &\cos u \end{pmatrix}. $$ The equation of the "swiss torus" surface of revolution is then $S(u,v) = R(u)\cdot C(v).$ This is a plot of the surface for $v\in [0,2\pi]$ and $u\in [0,2\pi]$ with $x_0=10$:

Related Question