8
$\begingroup$

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?
$\endgroup$
  • 2
    $\begingroup$ Your transcription of the code from your source is incorrect. As soon as you use the 1:1 code, the result is comparable. The colors can be dealt with by PlotTheme -> "Classic". $\endgroup$ – Yves Klett Jun 21 '16 at 9:24
  • $\begingroup$ Hi, I apologize for this. $\endgroup$ – Marion Jun 21 '16 at 12:34
  • 1
    $\begingroup$ Not to worry, have fun! $\endgroup$ – Yves Klett Jun 21 '16 at 14:04
  • 1
    $\begingroup$ FWIW: ExampleData[{"Geometry3D", "KleinBottle"}] $\endgroup$ – Chip Hurst Jun 21 '16 at 16:36
13
$\begingroup$

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.)

$\endgroup$
  • $\begingroup$ 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$? $\endgroup$ – murray Oct 8 '18 at 16:20
  • $\begingroup$ 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. $\endgroup$ – J. M. will be back soon Oct 8 '18 at 16:25
9
$\begingroup$

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

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Marion Jun 21 '16 at 12:35
8
$\begingroup$

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

$\endgroup$
  • $\begingroup$ This looks rather "lumpy" around the larger part of the "horn" once you move to the 3rd and 4th circles. $\endgroup$ – murray May 19 '18 at 0:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.