ROOT logo
// Draws the Klein bottle.
// Klein bottle is closed nonorientable surface that has no inside or
// outside. TF3 can be drawn in several styles:
//   default - like surface4
//   kMaple0 - very nice colours
//   kMaple1 - nice colours and outlines
//   kMaple2 - nice colour outlines.
// To switch between them, you can press 's' key.
// Author: Timur Pocheptsov

void gltf3()
{
   gStyle->SetCanvasPreferGL(1);
   TCanvas *cnv = new TCanvas("glc", "TF3: Klein bottle", 200, 10, 600, 600);
   // TCanvas *cnv = new TCanvas("glc", "TF3: Torus", 200, 10, 600, 600);

   TPaveLabel *title = new TPaveLabel(0.04, 0.86, 0.96, 0.98,
      "\"gl\" option for TF3. Select plot and press 's' to change the color.");
   title->SetFillColor(32);
   title->Draw();

   TPad *tf3Pad  = new TPad("box", "box", 0.04, 0.04, 0.96, 0.8);   
   tf3Pad->Draw();

   TFormula f1 = TFormula("f1", "x*x + y*y + z*z + 2*y - 1");
   TFormula f2 = TFormula("f2", "x*x + y*y + z*z - 2*y - 1");

   // Klein bottle with cutted top&bottom parts
   // The Klein bottle is a closed nonorientable surface that has no
   // inside or outside.

   TF3 *tf3 = new TF3("Klein Bottle","f1*(f2*f2-8*z*z) + 16*x*z*f2",
                      -3.5, 3.5, -3.5, 3.5, -2.5, 2.5);
   // Torus
   // TF3 *tf3 = new TF3("Torus","4*(x^4 +
   // (y^2+z^2)^2)+17*x^2*(y^2+z^2)-20*(x^2+y^2+z^2)+17", -2.5., 2.5.,
   // -2.5., 2.5., -2.5., 2.5.);

   tf3->SetFillColor(kRed);
   tf3Pad->cd();
   tf3->Draw("gl");
}
 gltf3.C:1
 gltf3.C:2
 gltf3.C:3
 gltf3.C:4
 gltf3.C:5
 gltf3.C:6
 gltf3.C:7
 gltf3.C:8
 gltf3.C:9
 gltf3.C:10
 gltf3.C:11
 gltf3.C:12
 gltf3.C:13
 gltf3.C:14
 gltf3.C:15
 gltf3.C:16
 gltf3.C:17
 gltf3.C:18
 gltf3.C:19
 gltf3.C:20
 gltf3.C:21
 gltf3.C:22
 gltf3.C:23
 gltf3.C:24
 gltf3.C:25
 gltf3.C:26
 gltf3.C:27
 gltf3.C:28
 gltf3.C:29
 gltf3.C:30
 gltf3.C:31
 gltf3.C:32
 gltf3.C:33
 gltf3.C:34
 gltf3.C:35
 gltf3.C:36
 gltf3.C:37
 gltf3.C:38
 gltf3.C:39
 gltf3.C:40
 gltf3.C:41
 gltf3.C:42
 gltf3.C:43
thumb