From 2f4de78325e53e8b4b4f3cb00b3d0d9e7f4870d3 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Fri, 5 Apr 2024 08:27:49 +0300 Subject: [PATCH] started writing the first chapter --- gl1/setup.tex | 2 ++ gl1/spaces.tex | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/gl1/setup.tex b/gl1/setup.tex index 707f395..cbbc145 100644 --- a/gl1/setup.tex +++ b/gl1/setup.tex @@ -1 +1,3 @@ \chapter{Setup \& hello world} + +% to setup na exei prota clear-color, kai meta ena trigono diff --git a/gl1/spaces.tex b/gl1/spaces.tex index 7940ef3..e86b560 100644 --- a/gl1/spaces.tex +++ b/gl1/spaces.tex @@ -1 +1,40 @@ \chapter{Transformations \& coordinate systems} + +\section{Overview} + +In the previous chapter we saw how to use GLUT to create a window in any +operating system, and then used OpenGL to fill it with a single color, and draw +our first 2D triangle onto it. In this chapter we will enter the world of +3-dimensions, and learn how to go from a single triangle, to rendering a +polygonal object in 3D space. To do that we'll have to grasp the concept of +coordinate systems, and how to transform vertices from one to another. OpenGL +will help us quite a lot in this, with its \em{matrix stacks}, but in +later chapters we will revisit the underlying mathematics and their +implementation in more detail. + +\section{Mathematical fundamentals} + +The fundamental mathematical tools necessary to do anything in 3D graphics, are +vectors, matrices, and the concept of coordinate systems from linear algebra. + +\subsection{Coordinate systems and vectors} + +A coordinate system represents a \em{space} which has a certain point as its +\em{origin}, the point from which every measurement starts, the place where all +coordinates are defined to be 0. It also has a number of basis vectors, defining +the axes of the coordinate system. By stepping varying distances along each +axis, we can reach any point in space. How much we step along each axis to reach +a certain point is defined by a pair of numbers in 2-space, or a triplet of +numbers in 3-space, or more generally an \em{n-tuple} for n-dimensional spaces. +These tuples are what we call \em{vectors}. + +Consider the triangle we defined in the previous chapter. We arbitrarily used +vectors $v_0 = (42, 42)$, $v_1 = (42, 42)$, and $v_2 = (42, 42)$ % TODO +to +define the positions in space of each vertex of the triangle. We chose these +numbers arbitrarily, because they will result in a big clearly visible triangle +in our case, due to the extends of the screen ranging from $-1$ to $1$ both +horizontally and vertically. In essence we were dealing with a coordinate +system, called \em{normalized screen space} or sometimes known by the initials +\em{NDC} (normalized device coordinates), which has its origin at the center of +our window, and basis vectors $i = (1, 0)$ and $j = (0, 1)$. -- 1.7.10.4