Skip to content
Exercise 3 for the Introduction to Computer Graphics course
C C++
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


<!DOCTYPE html>
    <title>Exercise 3 - Introduction to computer graphics</title>
        body {
            background-color: #101010;
            color: #F0F0F0;
            font-family: Helvetica;
            max-width: 800px;
            margin-left: auto;
            margin-right: auto;
            padding: 10px;

        h1 {
            background-color: #F0F0F0;
            color: #101010;
            padding: 10px;
            text-align: center;

        h2 {
            margin-top: 1.5em;

        .center {
            text-align: center;

        img {
            box-shadow: 0px 0px 15px white;
            -webkit-border-radius: 10px;
            -moz-border-radius: 10px;
            border-radius: 10px;

<h1>Introduction to computer graphics</h1>
by Amos Wenger and Javier Martín de Valmaseda
<h2>3.1 Introduction</h2>

<p>Not much to say here, except that we added ostream overloading to Vector2, Vector3, Vector4 and Matrix4 to make it easier to debug.</p>

<h2>3.2 Transformation and Translation (15 points)</h2>

<p>The initial render looked something like this:</p>

<p class='center'><img src="images/initial.png"></p>

<p>It was really not clear from the slides what to do in getScreenExtents() but we finally figured it out. When the projection matrix became correct, it looked like this:</p>

<p class='center'><img src="images/perspective.png"></p>
<p> For the translation we need to multiply the translate matrix to the transformationMatrix to get the final transformationMatrix.</p>

<p class='center'><img src="images/translation.png"></p>

<h2>3.3 Shaders (5 points)</h2>

<p>We had to find out to use gl_Color and gl_Normal, the diffuse shader was really simple to do.</p>

<p class='center'><img src="images/diffuse.png"></p>

<h2>3.4 Scale and Rotation (10 points)</h2>

<p>Scale was trivial. As for rotation, the slide were really helpful. We had to switch from atan(a / b) to atan2(a, b) because were getting INF/NANs</p>

<p class='center'><img src="images/scale-rotate.png"></p>

<h2>3.5 Clipping Planes (5 points)</h2>

<p>If we take a cross-section of the cube, we will see diferents shapes depend on the direction of the section, like squares and rectangles, lines.</p>
<p>Following the images of the clipping planes</p>

<p class='center'><img src="images/clipping1.png"></p>
<p class='center'><img src="images/clipping2.png"></p>
<p class='center'><img src="images/clipping3.png"></p>
<p class='center'><img src="images/clipping4.png"></p>
<p class='center'><img src="images/clipping5.png"></p>
<p class='center'><img src="images/clipping6.png"></p>

Something went wrong with that request. Please try again.