lehrkraefte:blc:math:povray:lektion5

This is an old revision of the document!


Rendern Sie folgenden Code und studieren Sie diesen. Stellen Sie danach Fragen, wenn Sie etwas nicht verstehen.

funktionen.pov
// Kamera
camera { 
  sky <0,0,1>           // Vektor, der festlegt, wo oben ist.
  right <-4/3,0,0>     // Bildverhaeltnis 4:3, plus Spiegelung für rechtsdrehendes System
  location <10,0,0>    // Position der Kamera
  look_at <0, 0, 0>    // Blickrichtung (erscheint im Bildmittelpunkt)
  angle 35             // Oeffnungswinkel der Kamera
}
 
// Lichtquellen
light_source { 
  <60,-20,80>              // Position des Lichts
  color rgb <1,1,1>     // Farbe des Lichts, als rot-gruen-blau Vektor (Komponenten 0 bis 1)
}
light_source { 
  <30,100,30>              // Position des Lichts
  color rgb <1,1,1>     // Farbe des Lichts, als rot-gruen-blau Vektor (Komponenten 0 bis 1)
}
 
// yz-Ebene
plane {x,0
  pigment { checker color rgb 0.2 color rgb 0.9 }
}
// y,z-Achse
union {
  cylinder { -2*y, 2*y, 0.05 }
  cylinder { -2*z, 2*z, 0.05 }
  cone {2*y, 0.1, 2.3*y, 0 }
  cone {2*z, 0.1, 2.3*z, 0 }
  text { ttf "timrom.ttf" "y" 0.1, <0,0,0>
    rotate 90*x
    rotate 90*z
    translate 2.3*y
  }
  text { ttf "timrom.ttf" "z" 0.1, <0,0,0>
    rotate 90*x
    rotate 90*z
    translate 1.8*z+0.2*y
  }
  pigment { color rgb z }
  finish { phong 0.95 }
}
 
// Berechnet den Funktionswert an der Stelle xx (x ist schon definiert)
#macro meinf(xx)
  xx*xx-2 // Wert der Funktion
#end
 
#declare starty=-2;
#declare endy=2;
#declare n=100;
#declare dy=(endy-starty)/n;
#while (starty<endy) 
  sphere { <0,starty, meinf(starty)>, 0.02
    pigment { color rgb x }
  }
  #declare starty=starty+dy;
#end

Die Funktion im oberen Code ist $f(x)=x^2-2$. Ändern Sie die Funktion auf folgende Funktionen ab:

  • $f(x) = -\frac{1}{2}x^2+1$
  • $f(x) = \sin(x)$ Die Funktion sin ist in POV-Ray definiert (Argument in Radiant).
  • $f(x) = |x|$ Die Betragsfunktion in POV-Ray ist abs(…) (absolute value).
  • $f(x) = \sqrt{x}$ Was müssen Sie anpassen? Die Wurzelfunktion in POV-Ray heisst sqrt(…).

Verbinden Sie jeweils zwei benachbarte Kugeln mit einem Zylinder mit gleichem Radius. So entsteht eine durchgehende Linie.

Eine Funktion kann auch mehr als eine Eingabe haben. In dieser Aufgabe betrachten wir eine Art Landschaft, wobei die Höhe $z$ aus den $x$- und $y$-Koordinaten berechnet wird. Im folgenden Code wird die Funktion $f(x)=\frac{1}{2}\left(x^2+y^2\right)$ abgebildet:

fxy.pov
// Kamera
camera { 
  sky <0,0,1>           // Vektor, der festlegt, wo oben ist.
  right <-4/3,0,0>     // Bildverhaeltnis 4:3, plus Spiegelung für rechtsdrehendes System
  location <5,2,5>    // Position der Kamera
  look_at <0, 0, 0>    // Blickrichtung (erscheint im Bildmittelpunkt)
  angle 35             // Oeffnungswinkel der Kamera
}
 
// Lichtquellen
light_source { 
  <60,-20,80>              // Position des Lichts
  color rgb <1,1,1>     // Farbe des Lichts, als rot-gruen-blau Vektor (Komponenten 0 bis 1)
}
light_source { 
  <30,100,30>              // Position des Lichts
  color rgb <1,1,1>     // Farbe des Lichts, als rot-gruen-blau Vektor (Komponenten 0 bis 1)
}
 
// xy-Ebene
plane {z,0
  pigment { checker color rgb 0.2 color rgb 0.9 }
}
 
#macro hoehe(xx,yy)
  0.5*(xx*xx+yy*yy)
#end
 
#declare startx = -1;
#declare endx = 1;
#declare starty=-1;
#declare endy=1;
#declare n=20;
#declare dx=(endx-startx)/n;
#declare dy=(endy-starty)/n;
 
#declare xx = startx;
#while (xx<endx)
  #declare yy = starty;
  #while (yy<endy) 
    sphere { <xx,yy,hoehe(xx,yy)>, 0.05
      pigment { color rgb x }
    }
    #declare yy=yy+dy;
  #end
  #declare xx=xx+dx;
#end

Rendern und studieren Sie den Code. Stellen Sie Fragen, wenn Sie etwas nicht verstehen.

Ändern Sie die Funktion hoehe ab, z.B.

  • $f(x,y) = \sin(x)+\sin(y)$
  • $f(x,y) = \cos\left(\sqrt{x^2+y^2}\right)$
  • $f(x,y) = 2^{-\sqrt{x^2+y^2}}\cos\left(\sqrt{x^2+y^2}\right)$
  • $f(x,y) = \cos(x)\cdot \cos(y)$

Fügen Sie zwischen benachbarten Kugeln Zylinder mit dem selben Radius ein.

  • lehrkraefte/blc/math/povray/lektion5.1496298449.txt.gz
  • Last modified: 2017/06/01 08:27
  • by Ivo Blöchliger