9

I have found the following parametrisation for a Klein bottle:

a = 6 Cos[2 u] (1 + Sin[u]);
b = 16 Sin[u];
c = 4 (1 - Cos[u]/2);
fx = If[Pi < u <= 0, a + c Cos[v + Pi], a + c Cos[u] Cos[v]];
fy = If[Pi < u < 2 Pi, b, b + c Sin[u] ];
fz = c Sin[v];

I am trying to plot it using

ParametricPlot3D[{fx, fy, fz}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, 
  Boxed -> False, Axes -> False]

but the result is not quite the Klein bottle.

enter image description here

The reference I am using is this one (page 141) where you can see the same parameterization.

  1. Any ideas why it does not work with me?
  2. Also how can I change the colours of the surface to be as in the book?
J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Marion
  • 429
  • 3
  • 8

3 Answers3

14

Here's my slight simplification of the Klein bottle parametric equations. I believe the original parametrization is due to Stewart Dickson (whose depiction of the bottle was in the "Graphics Gallery" of the old versions of The Mathematica Book).

ParametricPlot3D[{6 Cos[u] (1 + Sin[u]), 16 Sin[u], 0} + 2 (2 - Cos[u])
                 {Cos[Clip[u, {0, π}]] Cos[v], Sin[Clip[u, {0, π}]] Cos[v], Sin[v]},
                 {u, 0, 2 π}, {v, 0, 2 π}, Lighting -> "Classic", Mesh -> False,
                 PlotStyle -> Opacity[2/3, ColorData["Legacy", "AliceBlue"]]]

translucent Klein bottle

I have elected to use translucency instead to reveal the inner structure of the bottle. If you want to cut the bottle, just restrict the parameter ranges, like so:

ParametricPlot3D[{6 Cos[u] (1 + Sin[u]), 16 Sin[u], 0} + 2 (2 - Cos[u])
                 {Cos[Clip[u, {0, π}]] Cos[v], Sin[Clip[u, {0, π}]] Cos[v], Sin[v]},
                 {u, 0, 2 π}, {v, π, 2 π}, Mesh -> False, PlotTheme -> "Classic"]

half a bottle

(Have a look at Franzoni's article as well to see other possible variations.)

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
  • Is this immersed image of the Klein bottle in $\mathbb{R}^3$ some sort of projection of an embedding of the Klein bottle into $\mathbb{R}^4$? – murray Oct 08 '18 at 16:20
  • Not near my notes right now, but I recall this just follows Thomas Banchoff's procedure to make a surface with the required topology, and not necessarily derived from an $\mathbb R^4$ embedding. – J. M.'s missing motivation Oct 08 '18 at 16:25
10

Description

For fun, thought I give it a try. Below is an example of my attempt to Plot Kleins bottle.

Code

klein[u_, v_] := Module[{
   bx = 6 Cos[u] (1 + Sin[u]),
   by = 16 Sin[u],
   rad = 4 (1 - Cos[u]/2),
   X, Y, Z},
  X = If[Pi < u <= 2 Pi, bx + rad Cos[v + Pi], bx + rad Cos[u] Cos[v]];
  Y = If[Pi < u <= 2 Pi, by, by + rad Sin[u] Cos[v]];
  Z = rad Sin[v];
  {X, Y, Z}
  ]

ParametricPlot3D[klein[u, v], {u, 0, 2 Pi}, {v, 0, 2 Pi}, Axes -> False, Boxed -> False]

Output

klein bottle

e.doroskevic
  • 5,959
  • 1
  • 13
  • 32
  • thanks a lot. This is very nice and I have to admit I do not know to plot such things my self. May I ask if there is a way to cut the bottle in half (and in different angles) in order to see what it looks like "inside"? I want to use it to show to some students that there is a Mobius band inside. – Marion Jun 21 '16 at 12:35
9

This is just to give a solution based on minimal correction of the OP's code.

a[u_] := 6 Cos[u] (1 + Sin[u])
b[u_] := 16 Sin[u]
c[u_] := 4 (1 - Cos[u]/2)

fx[u_, v_] := If[Pi < u <= 2 Pi, a[u] + c[u] Cos[v + Pi], a[u] + c[u] Cos[u] Cos[v]];
fy[u_, v_] := If[Pi < u < 2 Pi, b[u], b[u] + c [u] Sin[u]];
fz[u_, v_] := c[u] Sin[v];

ParametricPlot3D[{fx[u, v], fy[u, v], fz[u, v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi}, 
  Boxed -> False, Axes -> False]

klein

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • This looks rather "lumpy" around the larger part of the "horn" once you move to the 3rd and 4th circles. – murray May 19 '18 at 00:35