Topological Tomfoolery in R: Plotting a Möbius Strip

By Peter Prevos

Plotting a Möbius Strip

(This article was first published on The Devil is in the Data, and kindly contributed to R-bloggers)

Topology is, according to Clifford Pickover, the “silly putty of mathematics”. This branch of maths studies the transformation of shapes, knots and other complex geometry problems. One of the most famous topics in topology is the Möbius strip. This shape has some unusual properties which have inspired many artists, inventors, mathematicians and magicians.

You can make a Möbius strip by taking a strip of paper, giving it one twist and glue the ends together to form a loop. If you now cut this strip lengthwise in half, you don’t end-up with two separate strips, but with one long one.

The Möbius strip can also be described with the following parametric equations (where , -1 leq v leq 1 and R is the radius of the loop):

x(u,v)= left(R+frac{v}{2} cos frac{u}{2}right)cos u
y(u,v)= left(R+frac{v}{2} cosfrac{u}{2}right)sin u
z(u,v)= frac{v}{2}sin frac{u}{2}

The mathematics of this set of parametric equations is not as compex as it looks. R is the radius of the ring, u is the polar angle of each point and v indicates the width of the strip. The polar angle u/2 indicates the number of half twists. To make the ring twist twice, change the anlge to u.

For my data science day job, I have to visualise some three-dimensional spaces so I thought I best learn how to do this by visualising a Möbis strip, using these three equations.

Plotting a Möbius Strip

The RGL package provides the perfect functionality to play with virtual Möbius strips. This package produces interactive three-dimensional plots that you can zoom and rotate. This package has many options to change lighting, colours, shininess and so on. The code to create for plotting a Möbius strip is straightforward.

The first section defines the parameters and converts the u and v sequences to a mesh (from the plot3D package). This function creates two matrices with every possible combination of u and v which are used to calculate the x, y, z points.

The last three lines define a 3D window with a white background and plot the 3D surface in blue. You can explore the figure with your mouse by zooming and rotating it. Parametric equations can be a bit of fun, play with the formula to change the shape and see what happens.

# Moebius strip
library(rgl)
library(plot3D)

# Define Parameters
R 

You can find the latest version of this code on GitHub.

Plotting a Möbius Strip: RGL output.

We can take it to the next level by plotting a three-dimensional Möbius strip, or a Klein Bottle. The parametric equations for the bottle are mind boggling:

x(u,v) = -frac{2}{15} cos u (3 cos{v}-30 sin{u}+90 cos^4{u} sin{u} -60 cos^6{u} sin{u} +5 cos{u} cos{v} sin{u})

y(u,v) = -frac{1}{15} sin u (3 cos{v}-3 cos^2{u} cos{v}-48 cos^4{u} cos{v} + 48 cos^6{u} cos{v} - 60 sin{u}+5 cos{u} cos{v} sin{u}-5 cos^3{u} cos{v} sin{u}-80 cos^5{u} cos{v} sin{u}+80 cos^7{u} cos{v} sin{u})

z(u,v) = frac{2}{15} (3+5 cos{u} sin{u}) sin{v}

Where: 0 leq u leq pi and 0 leq v leq 2leq.

The code to visualise this bottle is essentially the same, just more complex equations.

u 
Plotting a Klein Bottle in RGL

Plotting a Klein Bottle in RGL. Click to view RGL widget.

The RGL package has some excellent facilities to visualise three-dimensional objects, far beyond simple strips. I am still learning and am working toward using it to visualise bathymetric surveys of water reservoirs. Möbius strips are, however, a lot more fun.

Creating Real Möbius Strips

Even more fun than playing with virtual Möbius strips is to make some paper versions and start cutting, just like August Möbius did when he did his research. If you like to create a Möbius strip, you can recycle then purchase a large zipper from your local haberdashery shop, add some hook-and-loop fasteners to the ends and start playing. If you like to know more about the mathematics of the topological curiosity, then I can highly recommend Clifford Pickover's book on the topic.

Möbius strip zipper

Möbius strip zipper.

The Möbius Strip in Magic

In the first half of the twentieth century, many magicians used the Möbius strip as a magic trick. The great Harry Blackstone performed it regularly in his show.

If you are interested in magic tricks and Möbius strips, then you can read my ebook on the Afghan bands.

The Möbius Strip in Magic. A Treatise on the Afghan Bands

The post Topological Tomfoolery in R: Plotting a Möbius Strip appeared first on The Devil is in the Data.

To leave a comment for the author, please follow the link and comment on their blog: The Devil is in the Data.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

Source:: R News

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.