Steuerungstasten

nächste Folie (auch Enter oder Spacebar).
vorherige Folie
 d  schaltet das Zeichnen auf Folien ein/aus
 p  wechselt zwischen Druck- und Präsentationsansicht
CTRL  +  vergrößert die Folien
CTRL  -  verkleinert die Folien
CTRL  0  setzt die Größenänderung zurück

Das Weiterschalten der Folien kann ebenfalls durch das Klicken auf den rechten bzw. linken Folienrand erfolgen.

Notation

Typ Schriftart Beispiele
Variablen (Skalare) kursiv $a, b, x, y$
Funktionen aufrecht $\mathrm{f}, \mathrm{g}(x), \mathrm{max}(x)$
Vektoren fett, Elemente zeilenweise $\mathbf{a}, \mathbf{b}= \begin{pmatrix}x\\y\end{pmatrix} = (x, y)^\top,$ $\mathbf{B}=(x, y, z)^\top$
Matrizen Schreibmaschine $\mathtt{A}, \mathtt{B}= \begin{bmatrix}a & b\\c & d\end{bmatrix}$
Mengen kalligrafisch $\mathcal{A}, B=\{a, b\}, b \in \mathcal{B}$
Zahlenbereiche, Koordinatenräume doppelt gestrichen $\mathbb{N}, \mathbb{Z}, \mathbb{R}^2, \mathbb{R}^3$

Parallelprojektion

Parallelprojektion

  • Bei der Parallelprojektion werden die Objekte mit größerem Abstand zum Betrachter bzw. Kamera nicht kleiner
  • Es existieren keine Fluchtpunkte
perspektivische Projektion
Perspektivische Projektion
Parallelprojektion
Parallelprojektion
Quelle: 3D Model:Turbosquid (Standard Royalty Free License); Renderer: 3ds Max

Parallelprojektion

parallelprojection
Projektionsstrahlen
Bildebene
$x$
$y$
$z$
$\tilde{\mathbf{P}}$
$\mathbf{P}$
  • Die Projektionsstrahlen verlaufen parallel, d.h. das Projektionszentrum liegt im Unendlichen
  • Die Projektionsvorschrift zur Abbildung eines 3D Punkts $\mathbf{P}=(p_x,p_y,p_z)^\top$ auf einen Punkt $\tilde{\mathbf{P}}= (\tilde{p}_x,\tilde{p}_y,\tilde{p}_z)^\top$ auf der Bildebene der Kamera lautet:

    $\tilde{\mathbf{P}}= \left(p_x, p_y, 0 \right)^\top$

Parallelprojektion

  • Bei Verwendung von homogenen Koordinaten kann die Parallelprojektion wieder als $4 \times 4$ Matrix geschrieben werden:

    $\begin{align}\underline{\tilde{\mathbf{P}}} & = \begin{pmatrix}p_x \\ p_y \\ 0\\ 1\end{pmatrix} = \underbrace{\begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}}_{\mathtt{A}} \begin{pmatrix}p_x \\p_y \\ p_z\\ 1\end{pmatrix}\\ \underline{\tilde{\mathbf{P}}} &=\mathtt{A}\, \underline{\mathbf{P}} \end{align}$

Parallelprojektion in OpenGL

  • Die $x$-, $y$- und $z$- Koordinaten des Sichtvolumens sollen sich wieder jeweils in den Bereich $[-1;1]$ abbilden
  • Um dies zu erreichen, werden pro Koordinate zwei neue Parameter $\alpha$ und $\beta$ in die lineare Transformationsmatrix hinzugefügt
glortho
$\mathtt{A}$
$x$
$y$
$z$
$x$
$y$
$z$

$\mathtt{A} = \begin{bmatrix} \alpha_x & 0 & 0 & \beta_x \\ 0 & \alpha_y & 0 & \beta_y \\ 0 & 0 & -\alpha_z & \beta_z \\ 0 & 0 & 0 & 1 \end{bmatrix}$

Parallelprojektion in OpenGL

  • Beispielweise, soll für die $z$-Koordinate der Punkte auf der Near-Ebene gelten:
    $p_z=-z_n \quad \mapsto \quad \tilde{p}_z=-1$
    und für Punkte auf der Far-Ebene:
    $p_z=-z_f \quad \mapsto \quad \tilde{p}_z=1$

$\underline{\tilde{\mathbf{P}}} = \begin{pmatrix}\alpha_x \, p_x + \beta_x \\ \alpha_y \, p_y + \beta_y \\ -\alpha_z \, p_z + \beta_z \\ 1\end{pmatrix} = \begin{bmatrix} \alpha_x & 0 & 0 & \beta_x \\ 0 & \alpha_y & 0 & \beta_y \\ 0 & 0 & -\alpha_z & \beta_z \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{pmatrix}p_x \\p_y \\ p_z\\ 1\end{pmatrix} \in \mathbb{H}^3$

  • Nun können $\alpha_z$ und $\beta_z$ aus den Bedingungen für die Abbildung der $z$-Koordinate bestimmt werden:
    $\begin{align}p_z=-z_n \,&\mapsto \, \tilde{p}_z=-1 \quad \Rightarrow \alpha_z \, z_n + \beta_z = -1 \\ p_z=-z_f \, &\mapsto \, \tilde{p}_z=\ 1 \,\,\, \,\quad \Rightarrow \alpha_z \, z_f + \beta_z = 1\end{align}$

Parallelprojektion in OpenGL

glortho
$\mathtt{A}$
$x$
$y$
$z$
$x$
$y$
$z$
$x_r$
$x_l$
$y_t$
$y_b$
$z_n$
$z_f$
  • Auflösen des Gleichungssystems nach $\alpha_z$ und $\beta_z$ liefert:

    $\begin{align} \alpha_z &= \frac{2}{z_f-z_n}\\ \beta_z & = -\frac{z_f + z_n}{z_f-z_n}\end{align}$

  • Nach analogen Rechnungen für die $x$- und $y$-Koordinate, ergibt sich die Projektionsmatrix zu:

    $\mathtt{A} = \begin{bmatrix} \frac{2}{x_r-x_l} & 0 & 0 & -\frac{x_r + x_l}{x_r-x_l} \\ 0 & \frac{2}{y_t-y_b} & 0 & -\frac{y_t + y_b}{y_t-y_b} \\ 0 & 0 & \frac{-2}{z_f-z_n} & -\frac{z_f + z_n}{z_f-z_n} \\ 0 & 0 & 0 & 1 \end{bmatrix}$

Parallelprojektion in OpenGL

Erzeugen einer $4 \times 4$ Parallelprojektionsmatrix in OpenGL:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(left, right, bottom, top, near, far);

$\mathtt{A} = \begin{bmatrix} \frac{2}{\mathrm{right}-\mathrm{left}} & 0 & 0 & -\frac{\mathrm{right} + \mathrm{left}}{\mathrm{right}-\mathrm{left}} \\ 0 & \frac{2}{\mathrm{top}-\mathrm{bottom}} & 0 & -\frac{\mathrm{top} + \mathrm{bottom}}{\mathrm{top}-\mathrm{bottom}} \\ 0 & 0 & \frac{-2}{\mathrm{far}-\mathrm{near}} & -\frac{\mathrm{far} + \mathrm{near}}{\mathrm{far}-\mathrm{near}} \\ 0 & 0 & 0 & 1 \end{bmatrix}$

Klassifikation planarer Projektionen

projection_classification

Rechtwinklige Projektion - Hauptrisse

  • Hauptrisse sind Parallelprojektionen entlang der 3 Hauptrichtungen des kartesischen Koordinatensystems
  • Insgesamt gibt es 6 Hauptrisse, entlang $x$, $(-x)$, $y$, $(-y)$, $z$ und $(-z)$-Achse (Seitenansicht, Aufsicht, Vorderansicht)
  • Hauptrisse sind beliebt bei Konstruktionszeichnungen (z.B. im Maschinenbau oder in der Architektur)
  • Die verschiedenen Hauptrisse können z.B. durch eine zusätzliche 90 (oder 180) Grad Rotation erreicht werden

    $\mathtt{A} \mathtt{T}_{\mathrm{\small cam}}^{-1} = \mathtt{A} \, \mathtt{T}_R(90^\circ)$

Rechtwinklige Projektion - Axonometrie

  • Im Allgemeinen kann eine Rotation um die Achse $\mathbf{n}$ mit dem Winkel $\alpha$ betrachtet werden

    $\mathtt{A} \mathtt{T}_{\mathrm{\small cam}}^{-1} = \mathtt{A} \, \mathtt{T}_r(\mathbf{n}, \alpha)$

  • Die resultierende Abbildung wird rechtwinklige Projektion genannt

Rechtwinklige Projektion - Axonometrie

  • Die Klassifizierung der Projektion ergibt sich aus den Längen der abgebildeten Basisvektoren des kartesische Koordinatensystem
    • 3 Achsen haben die gleiche Länge: isometrisch
    • 2 Achsen haben die gleiche Länge: dimetrisch
    • Alle Achsen haben unterschiedliche Längen: trimetrisch
axonometic
isometrisch
dimetrisch
trimetrisch

Rechtwinklige Projektion - Axonometrie

  • Beispielsweise kann die Rotation um die $y$-Achse mit dem Winkel $\alpha$ und um die $x$-Achse mit $\beta$ betrachtet werden
axonometic_ab
$\mathbf{e}_x$
$\mathbf{e}_y$
$\mathbf{e}_z$
$\tilde{\mathbf{e}}_x$
$\tilde{\mathbf{e}}_y$
$\tilde{\mathbf{e}}_z$
$-\alpha$
$\beta$

Rechtwinklige Projektion - Axonometrie

$\begin{align} \mathtt{A} \mathtt{T}_{\mathrm{\small cam}}^{-1} & = \mathtt{A} \, \mathtt{T}_{r_x}(\beta) \, \mathtt{T}_{r_y}(\alpha)\\ & = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0& \cos \beta & -\sin \beta& 0 \\ 0 & \sin \beta & \cos \beta & 0 \\ 0 & 0 & 0 &1 \\ \end{bmatrix} \begin{bmatrix} \cos \alpha & 0& \sin \alpha& 0 \\ 0 & 1 & 0 & 0 \\ -\sin \alpha & 0 &\cos \alpha & 0 \\ 0 & 0 & 0 &1 \\ \end{bmatrix} \\ & = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} \cos \alpha & 0 & \sin \alpha & 0 \\ \sin \beta \sin \alpha & \cos \beta & -\sin \beta \cos \alpha & 0\\ - \cos \beta \sin \alpha & \sin \beta & \cos \beta \cos \alpha & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} \\ & = \begin{bmatrix} \cos \alpha & 0 & \sin \alpha & 0 \\ \sin \beta \sin \alpha & \cos \beta & -\sin \beta \cos \alpha & 0\\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ \end{bmatrix} \end{align}$

Rechtwinklige Projektion - Axonometrie

  • Die Basisvektoren bilden sich damit wie folgt ab:

    $ \underline{\tilde{\mathbf{e}}}_x = \begin{pmatrix}\cos \alpha\\ \sin \beta \sin \alpha \\ 0\\ 1\\ \end{pmatrix}, \quad \underline{\tilde{\mathbf{e}}}_y = \begin{pmatrix}0\\ \cos \beta \\ 0\\ 1\\ \end{pmatrix}, \quad \underline{\tilde{\mathbf{e}}}_z = \begin{pmatrix}\sin \alpha\\ -\sin \beta \cos \alpha \\ 0\\ 1\\ \end{pmatrix}$

  • Somit können die Längen der abgebildeten Basisvektoren berechnet und die rechtwinklige Projektion in isometrisch, dimetrisch oder trimetrisch klassifiziert werden:

    $\begin{align} |\tilde{\mathbf{e}}_x| &= \sqrt{\cos^2\alpha + (\sin \beta \sin \alpha)^2}\\ |\tilde{\mathbf{e}}_y| &= \sqrt{\cos^2\beta}\\ |\tilde{\mathbf{e}}_z| &= \sqrt{\sin^2\alpha + (\sin \beta \cos \alpha)^2}\\ \end{align}$

Beispiel: Axonometrie in OpenGL

opengl_axonometric

Beispiel: Axonometrie in OpenGL

class Renderer {
public:
  int mode;
private:
  double alpha;
  double beta;
  
public:
  Renderer() : mode(1), alpha(0.0), beta(0.0) {}

public:
  void display() {
    glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    if(mode == 1) { // isometric
      alpha = 45.0;
      beta = 180.0 /  M_PI * atan(1.0/sqrt(2.0));
    }
    if(mode == 2) { // dimetric
        alpha= 180.0 /  M_PI * atan(1.0/sqrt(7.0));
        beta = 180.0 /  M_PI * atan(1.0/(2.0*sqrt(2.0)));
    }
    if(mode == 3) { // trimetric
       alpha= 30.0;
       beta = 35.0;
    }

    if(mode < 4) {
      glRotatef( beta, 1.0, 0.0f, 0.0);
      glRotatef(-alpha, 0.0f, 1.0f, 0.0f);
    }

    if(mode == 4) { // isometric
      //alternativ implementation
      gluLookAt(1.0, 1.0, 1.0, // eye
                0.0, 0.0, 0.0, // look at
                0.0, 1.0, 0.0); //up
    }

    if(mode == 5) { // dimetric
        //alternativ implementation
      gluLookAt(1.0, 1.0, sqrt(7.0),
                0.0, 0.0, 0.0,
                0.0, 1.0, 0.0);
    }


    glColor3f(0.0f, 0.0f, 1.0f);
    drawCoordinateAxisZ();
    glColor3f(0.0f, 1.0f, 0.0f);
    drawCoordinateAxisY();
    glColor3f(1.0f, 0.0f, 0.0f);
    drawCoordinateAxisX();

    drawUnitCube();
  }

  void init() {
    glEnable(GL_DEPTH_TEST);
  }

  void resize(int w, int h) {
    double aspect = float(w)/float(h);
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-2.0*aspect, 2.0*aspect, -2.0, 2.0, -5.0, 5.0);
  }

  void getAbsLengthXYZ(float& lx, float& ly, float &lz) {
      double cb =  cos(beta/180.0*M_PI);
      double ca =  cos(alpha/180.0*M_PI);
      double sb =  sin(beta/180.0*M_PI);
      double sa =  sin(alpha/180.0*M_PI);
      lx = sqrt(ca*ca+sb*sb*sa*sa);
      ly = sqrt(cb*cb);
      lz = sqrt(sa*sa+sb*sb*ca*ca);
  }
  ...
};

Schiefwinklige Projektion

oblique
$\mathbf{e}_x$
$\mathbf{e}_y$
$\tilde{\mathbf{e}}_z$
$\mathbf{e}_z$
Kavalierprojektion
Kabinettprojektion
1
1
1
1
1
0.5
$\alpha$
$\beta$
  • Bei den schiefwinkligen Projektionen wird eine zusätzliche Scherung erlaubt
  • Bei klassischen schiefwinkligen Projektionen werden meist zwei Koordinatenachsen durch die Abbildung nicht verändert und eine Scherung auf die dritte angewendet
  • Die Projektionsrichtung dieser dritten Achse kann mit zwei Winkeln $\alpha$ und $\beta$ angegeben werden (siehe Zeichnung)
  • Der Winkel $\alpha$ bleibt bei der Projektion erhalten und entspricht dem Winkel zwischen der projizierten $z$- und $x$-Achse. Der Winkel $\beta$ steuert den Maßstab:
    • Kavalierprojektion: $x:z=1:1$
    • Kabinettprojektion: $x:z=2:1$

Schiefwinklige Projektion

  • Allgemeine schiefwinklige Projektion:

    $\mathtt{A} \mathtt{T}_{\mathrm{\small cam}}^{-1} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 & 0 & \frac{-\cos \alpha}{\tan \beta} & 0 \\ 0 & 1 & \frac{\sin \alpha}{\tan \beta} & 0 \\ 0 & 0 & \frac{-1}{\sin \beta} & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} =\begin{bmatrix} 1 & 0 & \frac{-\cos \alpha}{\tan \beta} & 0 \\ 0 & 1 & \frac{\sin \alpha}{\tan \beta} & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}$

Schiefwinklige Projektion

  • Bei Kavalierprojektion: $\beta$ = 45 Grad

    $\mathtt{A} \mathtt{T}_{\mathrm{\small cam}}^{-1} = \begin{bmatrix} 1 & 0 & -\cos \alpha & 0 \\ 0 & 1 & \sin \alpha & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}$

  • Bei Kabinettprojektion: $\beta$ = 63,4 Grad

    $\mathtt{A} \mathtt{T}_{\mathrm{\small cam}}^{-1} = \begin{bmatrix} 1 & 0 & \frac{-\cos \alpha}{2} & 0 \\ 0 & 1 & \frac{\sin \alpha}{2} & 0 \\ 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix}$

Beispiel: Schiefwinklige Projektion in OpenGL

opengl_oblique

Beispiel: Schiefwinklige Projektion in OpenGL

class Renderer {
public:
  int mode;
  double alpha;

public:
  Renderer() : mode(1), alpha(-45.0) {}

public:
  void display() {
    glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    float m[16]; // identity
    glGetFloatv(GL_MODELVIEW_MATRIX, m);
    float angle = (M_PI / 180.0f) * alpha;
    if(mode == 1) { // cavalier
      m[2*4+0] = -cos(angle);
      m[2*4+1] = sin(angle);
    }
    if(mode == 2) { // cabinet
      m[2*4+0] = -cos(angle)/2.0f;
      m[2*4+1] = sin(angle)/2.0f;
    }
    glMultMatrixf(m);

    glColor3f(0.0f, 0.0f, 1.0f);
    drawCoordinateAxisZ();
    glColor3f(0.0f, 1.0f, 0.0f);
    drawCoordinateAxisY();
    glColor3f(1.0f, 0.0f, 0.0f);
    drawCoordinateAxisX();

    drawUnitCube();
  }

  void init() {
    glEnable(GL_DEPTH_TEST);
  }

  void resize(int w, int h) {
    double aspect = float(w)/float(h);
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(-2.0*aspect, 2.0*aspect, -2.0, 2.0, -5.0, 5.0);
  }
...
};

Gibt es Fragen?

questions

Anregungen oder Verbesserungsvorschläge können auch gerne per E-mail an mich gesendet werden: Kontakt

Weitere Vorlesungsfolien

Folien auf Englisch (Slides in English)