Graphics Programming
2D Transformations
Thorsten Thormählen
October 31, 2022
Part 5, Chapter 1
Thorsten Thormählen
October 31, 2022
Part 5, Chapter 1
This is the print version of the slides.
Advance slides with the → key or
by clicking on the right border of the slide
Slides can also be advanced by clicking on the left or right border of the slide.
Type | Font | Examples |
---|---|---|
Variables (scalars) | italics | $a, b, x, y$ |
Functions | upright | $\mathrm{f}, \mathrm{g}(x), \mathrm{max}(x)$ |
Vectors | bold, elements row-wise | $\mathbf{a}, \mathbf{b}= \begin{pmatrix}x\\y\end{pmatrix} = (x, y)^\top,$ $\mathbf{B}=(x, y, z)^\top$ |
Matrices | Typewriter | $\mathtt{A}, \mathtt{B}= \begin{bmatrix}a & b\\c & d\end{bmatrix}$ |
Sets | calligraphic | $\mathcal{A}, B=\{a, b\}, b \in \mathcal{B}$ |
Number systems, Coordinate spaces | double-struck | $\mathbb{N}, \mathbb{Z}, \mathbb{R}^2, \mathbb{R}^3$ |
$\tilde{\mathbf{p}}= \begin{pmatrix} \tilde{x}\\ \tilde{y}\end{pmatrix} = \begin{pmatrix} x + t_x\\ y + t_y \end{pmatrix} = \mathbf{p} + \begin{pmatrix} t_x\\ t_y \end{pmatrix} = \mathbf{p} + \mathbf{t}$
class Renderer { private: void drawTriangle() { glBegin(GL_TRIANGLES); glVertex3f(-0.5f, -0.5f, 0.0f); glVertex3f( 0.5f, -0.5f, 0.0f); glVertex3f( 0.0f, 0.5f, 0.0f); glEnd(); } public: void init() {} void resize(int w, int h) { glViewport(0, 0, w, h); } void display() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glOrtho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); glLoadIdentity(); glColor3f(1.0f, 1.0f, 1.0f); drawTriangle(); glColor3f(0.0f, 0.0f, 1.0f); glScalef(0.5, 0.5, 0.0); // resize to 50% drawTriangle(); glColor3f(1.0f, 0.0f, 0.0f); glRotatef(45.0, 0.0, 0.0, 1.0); //rotate 45 degrees drawTriangle(); glColor3f(0.0f, 1.0f, 0.0f); glTranslatef(0.5, 0.5, 0.0); // translate drawTriangle(); } void dispose() {} };
Please notify me by e-mail if you have questions, suggestions for improvement, or found typos: Contact