COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15

Size: px
Start display at page:

Download "COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15"

Transcription

1 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15 Assignment 1 I Pillemer Student#: COS340A Date submitted: March 25, 2007 Question 1... p2 3 Question 2... p4 Question 3(a)... p5 7 Question 3(b)... p8 p9 Question 4... p10 Question 5(a)... p11 Question 5(b)... p12 Question 5(c)... p13 Question 6... p14 p15

2 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p2/15 Question 1 (Exercise 1.2 in ICG) In computer graphics, objects such as spheres are usually approximated by simpler objects constructed from flat polygons (polyhedra). Using lines of longitude and latitude, define a set of simple polygons that approximate a sphere centered at the origin. Can you use only quadrilaterals or only triangles? Using lines of longitude, centered around the origin I have approximated a sphere from flat polygons. Every vertex is equidistant from the origin and I have created 15 longitudinal lines and 10 latitudinal lines by which flat polygons are defined. I have used OpenGL to create an image of this sphere approximation. I have also rotated the sphere approximation to create four views of the sphere approximated by these flat polygons defined by 15 lines of longitude and 10 lines of latitude. Figure 1 An investigation of the polygons thus defined provides an graphical answer to the second part of the question; namely can one use only quadrilaterals to form the sphere approximation;

3 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p3/15 and can one use only triangles to form the sphere approximation. If you look at Figure 1 you will see that most of flat polygons are quadrilaterals; and at the equator these quadrilaterals could almost be called squares. However as one looks at the polygons as they move closer and closer to the poles you can see that the polygons become increasingly skewed until eventually becoming triangles. This is inevitable in any approximation of a sphere using polygons; in which the polygons are being defined by lines of latitude and longitude. Thus graphically it is clear the the area around the poles can not be approximated by flat quadrilaterals; and only by flat triangles. Now that I have shown the reason why a sphere cannot be approximated by quadrilaterals graphically; let me attempt to also prove it logically using reductio ad absurdam. First, let us assume that one can construct an approximated sphere with quadrilaterals. One such quadrilateral must be touching a pole. This quadrilateral must also have a side that is lying against the first latitudinal line. Now a second polygon must necessarily lie next to this polygon and it must also be touching the pole. This means that the sides of the quadrilaterals lying against the pole must necessarily have no width ie must be triangular. However since the polygons sides are being defined by lines of longitude and latitude; two of its sides are being created from the pole by longitudinal lines; and end at the first latitudinal line. Thus the the two quadrilaterals lying side by side at the pole are triangles. This is absurd; therefore my original assumption is incorrect and therefore one cannot construct an approximated sphere defined by lines of longitude and latitude using only flat quadrilaterals. If one used only flat quadrilateral shapes the poles would have to have holes at the poles to account for the fourth side of the quadrilaterals lying side by side. However it is possible for a sphere to be approximated using only flat triangular polygons. I have already shown above that a sphere can be approximated by flat polygons between lines of latitude and longitude and flat triangles between the poles and the first line of latitude from either pole. Now, all quadrilaterals can by having a line drawn from one corner to corner that is not already connected by a line to it; be divided into two flat triangles. Thus it is possible to construct an approximated sphere with polygons defined by lines of longitude and latitude using only flat triangles.

4 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p4/15 Question 2 (Question 1.7 in ICG) Consider the perspective views of the cube shown in Figure The one of the left is called a one point perspective because parallel lines in one direction of the cube along the sides of the top converge to a vanishing point in the image. In contrast, the image on the right is a two point perspective. Characterize the particular relationship between the viewer, or a simple camera, and the cube that determines why one is a two point perspective and the other a one point perspective. In the case of the one point perspective two faces of the cube are parallel to the projection plane from the viewer or simple camera. In the case of of the two point perspective the edges of the cube in one direction are parallel to the projection plane. Now to take this idea a little further, a three point perspective would be necessary if no edges and no faces of the cube were parallel to the viewer. There would now be three vanishing points from the perspective of the viewer; the third one vanishing above or below the horizon towards which the other two vanish. Escher uses a three point perspective in his artwork to curious effect and I have included a small copy of this artwork Ascending and Descending (Figure 2) both because it demonstrates three point perspective; and, for your amusement. Figure 2

5 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p5/15 Question 3 (a) /* two dimensional Koch snowflake */ /* generated using vector arithmatic */ /* and starting with an equilateral triangle */ #include <GL/glut.h> #include <math.h> #define RECURSION 3 void myinit() /* attributes */ glclearcolor(1.0, 1.0, 1.0, 1.0); /* white background */ glcolor3f(1.0, 0.0, 0.0); /* draw in red */ /* set up viewing */ /* 50.0 x 50.0 camera coordinate window with origin lower left */ glmatrixmode(gl_projection); glloadidentity(); gluortho2d(0.0, 50.0, 0.0, 50.0); glmatrixmode(gl_modelview); void swap(glfloat * a, GLfloat * b) GLfloat temp = *a; *a = *b; *b = temp; void divide_snowflake(glfloat *a, GLfloat *b, int n) int x=0; int y=1; GLfloat t[2][2]; GLfloat slope[2]; GLfloat midpoint[2]; GLfloat snowflake_point[2]; GLfloat y_magnitude;

6 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p6/15 int j; if (n>0) /* Using Pythagorus */ /* Special triangle has ratio of 1:sqrt(3):2 */ y_magnitude = sqrt(3.0); /* Find a point a third of the way along the line */ for ( j = 0; j < 2; j++) t[0][j] = a[j] +( b[j] a[j]) /3.0; /* Find a point two thirds of the way along the line */ for ( j = 0; j < 2; j++) t[1][j] = a[j] +( b[j] a[j]) /3.0 * 2.0 ; /* Find the midpoint */ for ( j = 0; j < 2; j++) midpoint[j] = a[j] +( b[j] a[j]) / 2.0 ; /* Find the vector for the relative base of the triangle */ for ( j = 0; j < 2; j++) slope[j] = (midpoint[j] t[0][j]); /* vector of slope */ /* I know this is the relative unit vector as this is a case of the special triangle 1:sqrt(3):2 */ swap(&slope[x],&slope[y]); /* normal vector with outward direction is required. In order to find that I am required to swap the dx,dy of the vector and then set the dx to dx.*/ slope[x] = slope[x]; /* Since I am working with the special triangle 1:sqrt(3):2 I know that relatively the magnitude of the vector will be sqrt(3) * the unit vector. I add the vector to the midpoint to locate the x,y position of the tip of the new koch snowflake point. */ for ( j = 0; j < 2; j++) snowflake_point[j] = midpoint[j] + y_magnitude * slope[j]; /* locate point */ /* I now make the recursive calls for all the new lines. */ divide_snowflake(a,t[0],n 1); divide_snowflake(t[0],snowflake_point,n 1); divide_snowflake(snowflake_point,t[1],n 1); divide_snowflake(t[1],b,n 1); else glvertex2fv(a); glvertex2fv(b);

7 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p7/15 void koch(glfloat *a, GLfloat *b, GLfloat *c, int n) divide_snowflake(a,b,n); divide_snowflake(b,c,n); divide_snowflake(c,a,n); void display() /* determine the vertexes of a equilateral triangle. */ GLfloat side = 30; GLfloat xstart = 10.0; GLfloat ystart = 18.0; GLfloat v[3][2] = xstart,ystart,xstart + side/2.0, ystart + side/2.0*sqrt(3),xstart + side, ystart; glclear(gl_color_buffer_bit); /*clear the window */ glbegin(gl_lines); /* Make the call to draw the snowflake. */ koch(v[0],v[1],v[2],recursion); glend(); glflush(); /* clear buffers */ int main(int argc, char** argv) /* standard GLUT initialization */ glutinit(&argc,argv); glutinitdisplaymode (GLUT_SINGLE GLUT_RGB); /* default, not needed */ glutinitwindowsize(500,500); /* 500 x 500 pixel window */ glutinitwindowposition(0,0); /* place window top left on display */ glutcreatewindow("koch snowflake"); /* window title */ glutdisplayfunc(display); /* display callback invoked when window opened */ myinit(); /* set attributes */ glutmainloop(); /* enter event loop */

8 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p8/15 (b) Screen Capture for n = 1

9 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p9/15 Screen Capture for n = 3

10 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p10/15 Question 4 (Exercise 2.12 in ICG) Devise a test to determine whether a two dimensional polygon is simple. I can determine quite a simple and straight forward test. First I would determine the equation for each line defining the edges of the polygon. I would then proceed to solve, pair wise, these equations and determine all the intersections. I would then be able to conclude if they intersect to form a polygon (ie that there is a polygon at all); and then furthermore to confirm that all the lines intersect outside the vertices. If they intersect within the vertices I will know that the polygon is complex. This is a computationally intensive test but it is assured to work.

11 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p11/15 Question 5 (Exercise 4.1 in ICG) Show that the following sequences commute: a) A rotation and a uniform scaling b) Two rotations about the same axis c) Two translations. a) Let R be a rotation and S be a uniform scaling. We know that S is a uniform scaling, so S = ti. Therefore RS = R(t,t,t ) = RtI = Rt = tr = tir = (t,t,t)r = SR. It is worth noting that a Rotation and a non uniform scaling does not commute.

12 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p12/15 b) The trigonometric identities for the sum of two angles are: = + = Now, = ; and similarly = Thus =. = Using the trigonometric identities for the sum of two angles I can simplify this to which equals Now I know that = And similar to the above = Therefore = ; ie Rotations on the same axis commute.

13 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p13/15 c) = = = Similarly, =. And, = ; hence I can conclude that two translations commute.

14 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p14/15 Question 6 (Exercise 4.8 in ICG) Derive the shear transformation from the rotation, translation and scaling transformations. I will show that the y shear transformation (and similarly the x shear transformation) can be derived from a rotation, a non uniform scaling and a rotation. First I assume that =. The reason that I assume this; is that I know that a shear transformation does not affect the area of the shape. Thus when I use the non uniform scaling transformation I must make sure that the volume remains the same. This can be done by setting the scaling factor of for and for i.e. the product of the two scaling factors must equal one. Thus whatever the rotation matrices I need; I know that the non uniform scaling matrix must be. By choosing = I make finding suitable rotation matrices simpler. Hence I am now attempting to find suitable transformation for the matrix =. As described above the non uniform scaling matrix of is a necessary transformation matrix in the derivation ensuring the area of the transformed shape remains the same. I now need to rotate the shape so that this non uniform scaling transformation has the effect desired; and then rotate the shape back to the required position in the co ordinate system. My next step is to determine the two rotation matrices. In order to do this I need to decide on a rotation angle.

15 COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p15/15 I choose that such that conversions of and.. This allows me to make use of the trigonometric This allows me to convert the rotation matrix into ; which can be simplified to. Similarly, = = ; which can be simplified to. Furthermore = = ; which can be simplified to. I now try the different rotations until I find rotations that result in the shear matrix. In this manner, using trial and error, it can be seen that = = =. The case is similar with a x shear; it is the transpose. Thus I have derived a rotation, a non uniform scaling and a rotation that is identical to the shear matrix.

Programming with OpenGL Part 3: Three Dimensions

Programming with OpenGL Part 3: Three Dimensions Programming with OpenGL Part 3: Three Dimensions Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Objectives Develop a more sophisticated

More information

Computer Graphics (Basic OpenGL)

Computer Graphics (Basic OpenGL) Computer Graphics (Basic OpenGL) Thilo Kielmann Fall 2008 Vrije Universiteit, Amsterdam kielmann@cs.vu.nl http://www.cs.vu.nl/ graphics/ Computer Graphics (Basic OpenGL, Input and Interaction), ((57))

More information

Lecture 3. Understanding of OPenGL programming

Lecture 3. Understanding of OPenGL programming Lecture 3 Understanding of OPenGL programming What is OpenGL GL: stands for Graphic Library Software interface for rendering purposes for 2D or 3D geometric data objects. Various Pieces gl: The basic libraries.

More information

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815 Computer Graphics Autumn 2009 Outline 1 Labs 2 Labs Outline 1 Labs 2 Labs Labs Week02 lab Marking 8 10 labs in total each lab worth 2 3% of overall grade marked on attendance and completion of lab completed

More information

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++ Computer Graphics Graphics Programming August 31, 2005 Contents Our Goal in This Chapter Programming of the Sierpinski gasket How To? Programming with OpenGL and C/C++ OpenGL API (Application Programmer

More information

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1 Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1 1. The endpoints of a given line are (0, 0) and (18, 6). Compute the first 4 values of y manually using Bresenham's Line Algorithm as x steps

More information

Announcements OpenGL. Computer Graphics. Spring CS4815

Announcements OpenGL. Computer Graphics. Spring CS4815 Computer Graphics Spring 2017-2018 Outline 1 2 Tutes and Labs Tute02, vector review (see matrix) Week02 lab Lab Marking 10 labs in total each lab worth 3% of overall grade marked on attendance and completion

More information

Introduction to OpenGL: Part 2

Introduction to OpenGL: Part 2 Introduction to OpenGL: Part 2 Introduction to OpenGL: Part 2 A more complex example recursive refinement Introduction to OpenGL: Part 2 A more complex example recursive refinement Can OpenGL draw continuous

More information

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Computer Graphics. Making Pictures. Computer Graphics CSC470 1 Computer Graphics Making Pictures Computer Graphics CSC470 1 Getting Started Making Pictures Graphics display: Entire screen (a); windows system (b); [both have usual screen coordinates, with y-axis y

More information

by modifying the glutinitwindowsize() function you can change the screen size to whatever you please.

by modifying the glutinitwindowsize() function you can change the screen size to whatever you please. Zoe Veale Lab 2 Draw2 part 1: I edited the glutinitwindowsize() function tom change the size of my screen window. int main(int argc, char** argv) glutinit(&argc, argv); //initialize toolkit glutinitdisplaymode

More information

Graphics Programming

Graphics Programming Graphics Programming 3 rd Week, 2011 OpenGL API (1) API (application programming interface) Interface between an application program and a graphics system Application Program OpenGL API Graphics Library

More information

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M UNIT 7 LIGHTING AND SHADING 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M Ans: Phong developed a simple model that can be computed rapidly It considers three

More information

Drawing Primitives. OpenGL basics

Drawing Primitives. OpenGL basics CSC 706 Computer Graphics / Dr. N. Gueorguieva 1 OpenGL Libraries Drawing Primitives OpenGL basics OpenGL core library OpenGL32 on Windows GL on most unix/linux systems (libgl.a) OpenGL Utility Library

More information

COMPUTER GRAPHICS LAB # 3

COMPUTER GRAPHICS LAB # 3 COMPUTER GRAPHICS LAB # 3 Chapter 2: COMPUTER GRAPHICS by F.S HILLs. Initial steps in drawing figures (polygon, rectangle etc) Objective: Basic understanding of simple code in OpenGL and initial steps

More information

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field Cameras (and eye) Ideal Pinhole Real Pinhole Real + lens Depth of field 1 Z-buffer How do we draw objects? Polygon Based Fast Raytracing Ray/Object intersections Slow Copyright Pixar 2 Raytracing for each

More information

Lectures OpenGL Introduction

Lectures OpenGL Introduction Lectures OpenGL Introduction By Tom Duff Pixar Animation Studios Emeryville, California and George Ledin Jr Sonoma State University Rohnert Park, California 2004, Tom Duff and George Ledin Jr 1 What is

More information

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson Syllabus 1) First program and introduction to data types and control structures with applications for games learning how to use the programming

More information

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction: Graphics Programming Chapter 2 Introduction: - Our approach is programming oriented. - Therefore, we are going to introduce you to a simple but informative problem: the Sierpinski Gasket - The functionality

More information

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall Programming with OpenGL Part 2: Complete Programs 91.427 Computer Graphics I, Fall 2008 1 1 Objectives Refine first program Alter default values Introduce standard program structure Simple viewing 2-D

More information

Using OpenGL with CUDA

Using OpenGL with CUDA Using OpenGL with CUDA Installing OpenGL and GLUT; compiling with nvcc Basics of OpenGL and GLUT in C Interoperability between OpenGL and CUDA OpenGL = Open Graphic Library creation of 3D graphic primitives

More information

Assignment 1. Simple Graphics program using OpenGL

Assignment 1. Simple Graphics program using OpenGL Assignment 1 Simple Graphics program using OpenGL In this assignment we will use basic OpenGL functions to draw some basic graphical figures. Example: Consider following program to draw a point on screen.

More information

PART-I: Lab for MCS-051 (Advanced Internet Technologies)

PART-I: Lab for MCS-051 (Advanced Internet Technologies) PART-I: Lab for MCS-051 (Advanced Internet Technologies) Q.1. Write a Program using Servlet and JDBC for developing online application for students attendance management for MCA V semester students of

More information

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3) Computer Graphics (Fall 2008) COMS 4160, Lecture 9: OpenGL 1 http://www.cs.columbia.edu/~cs4160 To Do Start thinking (now) about HW 3. Milestones are due soon. Course Course 3D Graphics Pipeline 3D Graphics

More information

QUESTION 1 [10] 2 COS340-A October/November 2009

QUESTION 1 [10] 2 COS340-A October/November 2009 2 COS340-A QUESTION 1 [10] a) OpenGL uses z-buffering for hidden surface removal. Explain how the z-buffer algorithm works and give one advantage of using this method. (5) Answer: OpenGL uses a hidden-surface

More information

Basic Graphics Programming

Basic Graphics Programming 15-462 Computer Graphics I Lecture 2 Basic Graphics Programming Graphics Pipeline OpenGL API Primitives: Lines, Polygons Attributes: Color Example January 17, 2002 [Angel Ch. 2] Frank Pfenning Carnegie

More information

Programming with OpenGL Part 1: Background

Programming with OpenGL Part 1: Background Programming with OpenGL Part 1: Background Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico 1 Objectives Development of the OpenGL API

More information

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008 CS559: Computer Graphics Lecture 2: OpenGL Transformation Li Zhang Spring 28 Today Transformation in OpenGL Reading Chapter 3 Last time Primitive Details glpolygonmode(glenum face, GLenum mode); face:

More information

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW OpenGL Syntax Functions have prefix gl and initial capital letters for each word glclearcolor(), glenable(), glpushmatrix() glu for GLU functions glulookat(), gluperspective() constants begin with GL_,

More information

Precept 2 Aleksey Boyko February 18, 2011

Precept 2 Aleksey Boyko February 18, 2011 Precept 2 Aleksey Boyko February 18, 2011 Getting started Initialization Drawing Transformations Cameras Animation Input Keyboard Mouse Joystick? Textures Lights Programmable pipeline elements (shaders)

More information

3D computer graphics: geometric modeling of objects in the computer and rendering them

3D computer graphics: geometric modeling of objects in the computer and rendering them SE313: Computer Graphics and Visual Programming Computer Graphics Notes Gazihan Alankus, Spring 2012 Computer Graphics 3D computer graphics: geometric modeling of objects in the computer and rendering

More information

Computer Graphics: Line Drawing Algorithms

Computer Graphics: Line Drawing Algorithms Computer Graphics: Line Drawing Algorithms 1 Graphics hardware The problem scan conversion Considerations Line equations Scan converting algorithms A very simple solution The DDA algorithm, Bresenham algorithm

More information

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks, Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks, Hierarchical Modeling Hofstra University 1 Modeling complex objects/motion Decompose object hierarchically

More information

Computer Graphics. OpenGL

Computer Graphics. OpenGL Computer Graphics OpenGL What is OpenGL? OpenGL (Open Graphics Library) is a library for computer graphics It consists of several procedures and functions that allow a programmer to specify the objects

More information

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Teacher Assistant : Tamir Grossinger   Reception hours: by  - Building 37 / office -102 Assignments: 4 programing using Teacher Assistant : Tamir Grossinger email: tamirgr@gmail.com Reception hours: by email - Building 37 / office -102 Assignments: 4 programing using C++ 1 theoretical You can find everything you need in

More information

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program Comp 410/510 Computer Graphics Spring 2017 Programming with OpenGL Part 2: First Program Objectives Refine the first program Introduce a standard program structure - Initialization Program Structure Most

More information

6. Make use of glviewport() to display two sine curves on the same screen, one on the

6. Make use of glviewport() to display two sine curves on the same screen, one on the Duc Nguyen CSE-420: Computer Graphics 10/17/18 1. Modify lines.cpp to display lines in the following patterns: a. a long dash and a dot, (.. ) b. two close dots followed by a distant dot (...... ) 2. Modify

More information

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013 CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013 Reading: See any standard reference on OpenGL or GLUT. Basic Drawing: In the previous lecture, we showed how to create a window in GLUT,

More information

Introduction to Computer Graphics with OpenGL/GLUT

Introduction to Computer Graphics with OpenGL/GLUT Introduction to Computer Graphics with OpenGL/GLUT What is OpenGL? A software interface to graphics hardware Graphics rendering API (Low Level) High-quality color images composed of geometric and image

More information

OpenGL for dummies hello.c #include int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode (GLUT_SINGLE GLUT_RGB); glutinitwindowsize (250, 250); glutinitwindowposition

More information

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D CS334 Spring 2012 Daniel G. Aliaga Department of Computer Science Purdue University Computer Graphics Pipeline Geometric Primitives

More information

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations #include int main(int argc, char** argv) { glutinit(&argc, argv); Typical OpenGL/GLUT Main Program // GLUT, GLU, and OpenGL defs // program arguments // initialize glut and gl // double buffering

More information

Andrew Yenalavitch Homework 1 CSE Fall 2014

Andrew Yenalavitch Homework 1 CSE Fall 2014 Andrew Yenalavitch Homework 1 CSE 420 - Fall 2014 1.) ( 20 points ) In the class, we have discussed how to draw a line given by y = m x + b using Besenham's algorithm with m 1. Extend the algorithm to

More information

Computer Graphics Course 2005

Computer Graphics Course 2005 Computer Graphics Course 2005 Introduction to GLUT, GLU and OpenGL Administrative Stuff Teaching Assistant: Rony Goldenthal Reception Hour: Wed. 18:00 19:00 Room 31 (Ross 1) Questions: E-mail: cg@cs Newsgroups:

More information

Drawing and Coordinate Systems

Drawing and Coordinate Systems Drawing and Coordinate Systems Coordinate Systems Screen Coordinate system World Coordinate system World window Viewport Window to viewport mapping Screen Coordinate System Glut OpenGL (0,0) Screen Coordinate

More information

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008 CS559: Computer Graphics Lecture 12: OpenGL Li Zhang Spring 2008 Reading Redbook Ch 1 & 2 So far: 3D Geometry Pipeline Model Space (Object Space) Rotation Translation Resizing World Space M Rotation Translation

More information

CS 4204 Computer Graphics

CS 4204 Computer Graphics CS 4204 Computer Graphics OpenGL Basics Yong Cao Virginia Tech References: 2001 Siggraph, An Interactive Introduction to OpenGL Programming, Dave Shreiner,Ed Angel, Vicki Shreiner Official Presentation

More information

BOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR

BOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR COMPUTER GRAPHICS LECTURE 07 BOUNCING BALL IMRAN IHSAN ASSISTANT PROFESSOR WWW.IMRANIHSAN.COM /* * GL07BouncingBall.cpp: A ball bouncing inside the window */ #include // for MS Windows #include

More information

Programming using OpenGL: A first Introduction

Programming using OpenGL: A first Introduction Programming using OpenGL: A first Introduction CMPT 361 Introduction to Computer Graphics Torsten Möller Machiraju/Zhang/Möller 1 Today Overview GL, GLU, GLUT, and GLUI First example OpenGL functions and

More information

GEOMETRIC OBJECTS AND TRANSFORMATIONS I

GEOMETRIC OBJECTS AND TRANSFORMATIONS I Computer UNIT Graphics - 4 and Visualization 6 Hrs GEOMETRIC OBJECTS AND TRANSFORMATIONS I Scalars Points, and vectors Three-dimensional primitives Coordinate systems and frames Modelling a colored cube

More information

Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL

Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL Visual Computing and Multimedia Abel J. P. Gomes 1. Getting Started 2. Installing Graphics Libraries: OpenGL and GLUT 3. Setting up an IDE to run graphics programs in OpenGL/GLUT 4. A First OpenGL/GLUT

More information

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt CS334 Fall 2015 Daniel G. Aliaga Department of Computer Science Purdue University Books (and by now means complete ) Interactive Computer

More information

Transformation Pipeline

Transformation Pipeline Transformation Pipeline Local (Object) Space Modeling World Space Clip Space Projection Eye Space Viewing Perspective divide NDC space Normalized l d Device Coordinatesd Viewport mapping Screen space Coordinate

More information

Bob s Concise Introduction to Doxygen

Bob s Concise Introduction to Doxygen Bob s Concise Introduction to Doxygen by Robert S Laramee Visual and Interactive Computing Group Department of Computer Science Swansea University Swansea, Wales, UK 1 Comment Standard February 14, 2011

More information

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5) 5493S Computer Graphics Exercise Solution (Chapters 4-5). Given two nonparallel, three-dimensional vectors u and v, how can we form an orthogonal coordinate system in which u is one of the basis vectors?

More information

CS380: Computer Graphics Basic OpenGL Structure. Sung-Eui Yoon ( 윤성의 ) Course URL:

CS380: Computer Graphics Basic OpenGL Structure. Sung-Eui Yoon ( 윤성의 ) Course URL: CS380: Computer Graphics Basic OpenGL Structure Sung-Eui Yoon ( 윤성의 ) Course URL: http://sglab.kaist.ac.kr/~sungeui/cg Class Objectives Understand the basic OpenGL program structure and how OpenGL supports

More information

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12 Announcement Homework 1 has been posted in dropbox and course website Due: 1:15 pm, Monday, September 12 Today s Agenda Primitives Programming with OpenGL OpenGL Primitives Polylines GL_POINTS GL_LINES

More information

1.2 Basic Graphics Programming

1.2 Basic Graphics Programming Fall 2018 CSCI 420: Computer Graphics 1.2 Basic Graphics Programming Hao Li http://cs420.hao-li.com 1 Last time Last Time Story Computer Graphics Image Last Time 3D Printing 3D Capture Animation Modeling

More information

OpenGL Introduction Computer Graphics and Visualization

OpenGL Introduction Computer Graphics and Visualization Fall 2009 2 OpenGL OpenGL System Interaction Portable Consistent visual display regardless of hardware, OS and windowing system Callable from Ada, C, C++, Fortran, Python, Perl and Java Runs on all major

More information

Interaction Computer Graphics I Lecture 3

Interaction Computer Graphics I Lecture 3 15-462 Computer Graphics I Lecture 3 Interaction Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations January 21, 2003 [Angel Ch. 3] Frank Pfenning Carnegie Mellon

More information

2D Drawing Primitives

2D Drawing Primitives THE SIERPINSKI GASKET We use as a sample problem the drawing of the Sierpinski gasket an interesting shape that has a long history and is of interest in areas such as fractal geometry. The Sierpinski gasket

More information

Basic Graphics Programming

Basic Graphics Programming CSCI 480 Computer Graphics Lecture 2 Basic Graphics Programming January 11, 2012 Jernej Barbic University of Southern California http://www-bcf.usc.edu/~jbarbic/cs480-s12/ Graphics Pipeline OpenGL API

More information

Drawing and Coordinate Systems

Drawing and Coordinate Systems Drawing and Coordinate Systems Coordinate Systems World Coordinate system World window Screen Coordinate system Viewport Window to viewport mapping Screen Coordinate System Glut OpenGL (0,0) 0) Screen

More information

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API) CSCI 420 Computer Graphics Lecture 2 Basic Graphics Programming Teaching Assistant Yijing Li Office hours TBA Jernej Barbic University of Southern California Graphics Pipeline OpenGL API Primitives: Lines,

More information

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

Lecture 2 CISC440/640 Spring Department of Computer and Information Science Lecture 2 CISC440/640 Spring 2015 Department of Computer and Information Science Today s Topic The secrets of Glut-tony 2 So let s do some graphics! For the next week or so this is your world: -1 1-1 1

More information

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM 3213 - INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4 C++ - OpenGL Part 1- C++ - Texture Mapping 1. Download texture file and put it into your current folder

More information

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued CS 543 - Computer Graphics: OpenGL, Continued by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Last time. OpenGL set up Basic structure OpenGL skeleton Callback functions, etc. R.W.

More information

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued CS 543 - Computer Graphics: OpenGL, Continued by Robert W. Lindeman gogo@wpi.edu (with help from Emmanuel Agu ;-) Last time. OpenGL set up Basic structure OpenGL skeleton Callback functions, etc. R.W.

More information

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps)

Modeling Objects by Polygonal Approximations. Linear and Affine Transformations (Maps) Modeling Objects by Polygonal Approximations Define volumetric objects in terms of surfaces patches that surround the volume Each surface patch is approximated set of polygons Each polygon is specified

More information

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science CSC 307 1.0 Graphics Programming Department of Statistics and Computer Science Graphics Programming OpenGL 3D Drawing 2 3D Graphics Projections Getting 3D to 2D 3D scene 2D image 3 Projections Orthographic

More information

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers

UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers UNIVERSITY OF NEBRASKA AT OMAHA Computer Science 4620/8626 Computer Graphics Spring 2014 Homework Set 1 Suggested Answers 1. How long would it take to load an 800 by 600 frame buffer with 16 bits per pixel

More information

Exercises for Chapter Three You know you've got to exercise your brain just like your muscles. Will Rogers ( )

Exercises for Chapter Three You know you've got to exercise your brain just like your muscles. Will Rogers ( ) Exercises for Chapter Three You know you've got to exercise your brain just like your muscles. Will Rogers (1879 1935) Investigation Exercise 3.1. (a) Construct a tessellation. (Directions for construction.)

More information

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II Emmanuel Agu Recall: OpenGL Skeleton void main(int argc, char** argv){ // First initialize toolkit, set display mode and create window glutinit(&argc,

More information

Boardworks Ltd KS3 Mathematics. S1 Lines and Angles

Boardworks Ltd KS3 Mathematics. S1 Lines and Angles 1 KS3 Mathematics S1 Lines and Angles 2 Contents S1 Lines and angles S1.1 Labelling lines and angles S1.2 Parallel and perpendicular lines S1.3 Calculating angles S1.4 Angles in polygons 3 Lines In Mathematics,

More information

Interaction. CSCI 480 Computer Graphics Lecture 3

Interaction. CSCI 480 Computer Graphics Lecture 3 CSCI 480 Computer Graphics Lecture 3 Interaction January 18, 2012 Jernej Barbic University of Southern California Client/Server Model Callbacks Double Buffering Hidden Surface Removal Simple Transformations

More information

Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio)

Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio) Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Screen Coordinate System

More information

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益 Modeling Transform Chapter 4 Geometric Transformations 李同益 Specify transformation for objects Allow definitions of objects in own coordinate systems Allow use of object definition multiple times in a scene

More information

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008 CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008 2008/2/3 Slide 2 I Am Your TA Name : Wei-Wen Wen Feng 4th Year Graduate Student in Graphics I will be Holding discussion/tutorial

More information

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Ulf Assarsson Department of Computer Engineering Chalmers University of Technology 1. I am located in room 4115 in EDIT-huset 2. Email: 3. Phone: 031-772 1775 (office) 4. Course assistant: Tomas Akenine-Mőller

More information

Display Lists in OpenGL

Display Lists in OpenGL Display Lists in OpenGL Display lists are a mechanism for improving performance of interactive OpenGL applications. A display list is a group of OpenGL commands that have been stored for later execution.

More information

CS 432 Interactive Computer Graphics

CS 432 Interactive Computer Graphics CS 432 Interactive Computer Graphics Lecture 1 Part 3 Anatomy of OpenGL Programs Matt Burlick - Drexel University - CS 432 1 Reading Angel Chapter 2 Red Book Chapter 4 Matt Burlick - Drexel University

More information

UNIT 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS-1

UNIT 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS-1 UNIT 4 GEOMETRIC OBJECTS AND TRANSFORMATIONS-1 1. Explain the complete procedure of converting a world object frame into camera or eye frame, using the model view matrix. (Jun2012) 10M Ans: World Space

More information

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES

SOURCES AND URLS BIBLIOGRAPHY AND REFERENCES In this article, we have focussed on introducing the basic features of the OpenGL API. At this point, armed with a handful of OpenGL functions, you should be able to write some serious applications. In

More information

Lecture 3 Advanced Computer Graphics (CS & SE )

Lecture 3 Advanced Computer Graphics (CS & SE ) Lecture 3 Advanced Computer Graphics (CS & SE 233.420) Programming with OpenGL Program Structure Primitives Attributes and States Programming in three dimensions Inputs and Interaction Working with Callbacks

More information

C OMPUTER G RAPHICS Thursday

C OMPUTER G RAPHICS Thursday C OMPUTER G RAPHICS 2017.04.27 Thursday Professor s original PPT http://calab.hanyang.ac.kr/ Courses Computer Graphics practice3.pdf TA s current PPT not uploaded yet GRAPHICS PIPELINE What is Graphics

More information

CSC 470 Computer Graphics

CSC 470 Computer Graphics CSC 470 Computer Graphics Transformations of Objects CSC 470 Computer Graphics, Dr.N. Georgieva, CSI/CUNY 1 Transformations of objects - 2D CSC 470 Computer Graphics, Dr.N. Georgieva, CSI/CUNY 2 Using

More information

Graphics Hardware and OpenGL

Graphics Hardware and OpenGL Graphics Hardware and OpenGL Ubi Soft, Prince of Persia: The Sands of Time What does graphics hardware have to do fast? Camera Views Different views of an object in the world 1 Camera Views Lines from

More information

OpenGL/GLUT Intro. Week 1, Fri Jan 12

OpenGL/GLUT Intro. Week 1, Fri Jan 12 University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner OpenGL/GLUT Intro Week 1, Fri Jan 12 http://www.ugrad.cs.ubc.ca/~cs314/vjan2007 News Labs start next week Reminder:

More information

Introduction to OpenGL

Introduction to OpenGL Introduction to OpenGL Tutorial 1: Create a window and draw a 2D square Introduction: The aim of the first tutorial is to introduce you to the magic world of graphics based on the OpenGL and GLUT APIs.

More information

Reading on the Accumulation Buffer: Motion Blur, Anti-Aliasing, and Depth of Field

Reading on the Accumulation Buffer: Motion Blur, Anti-Aliasing, and Depth of Field Reading on the Accumulation Buffer: Motion Blur, Anti-Aliasing, and Depth of Field 1 The Accumulation Buffer There are a number of effects that can be achieved if you can draw a scene more than once. You

More information

Answer Key: Three-Dimensional Cross Sections

Answer Key: Three-Dimensional Cross Sections Geometry A Unit Answer Key: Three-Dimensional Cross Sections Name Date Objectives In this lesson, you will: visualize three-dimensional objects from different perspectives be able to create a projection

More information

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI) Computer Graphics CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Recall: OpenGL Skeleton void main(int argc, char** argv){ // First initialize

More information

Mrs. Daniel s Geometry Vocab List

Mrs. Daniel s Geometry Vocab List Mrs. Daniel s Geometry Vocab List Geometry Definition: a branch of mathematics concerned with questions of shape, size, relative position of figures, and the properties of space. Reflectional Symmetry

More information

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Ulf Assarsson Department of Computer Engineering Chalmers University of Technology Tracing Photons One way to form an image is to follow rays of light from a point source finding which rays enter the lens

More information

Meshing and Geometry

Meshing and Geometry Meshing and Geometry Points in OpenGL glbegin(gl_points); glvertex2fv(p0); glvertex2fv(p1); p7 p0 p1 glvertex2fv(p2); glvertex2fv(p3); p6 p2 glvertex2fv(p4); glvertex2fv(p5); p5 p3 glvertex2fv(p6); glvertex2fv(p7);

More information

RECITATION - 1. Ceng477 Fall

RECITATION - 1. Ceng477 Fall RECITATION - 1 Ceng477 Fall 2007-2008 2/ 53 Agenda General rules for the course General info on the libraries GLUT OpenGL GLUI Details about GLUT Functions Probably we will not cover this part 3/ 53 General

More information

Computer graphics MN1

Computer graphics MN1 Computer graphics MN1 http://www.opengl.org Todays lecture What is OpenGL? How do I use it? Rendering pipeline Points, vertices, lines,, polygons Matrices and transformations Lighting and shading Code

More information

Introduction to OpenGL

Introduction to OpenGL Introduction to OpenGL Banafsheh Azari http://www.uni-weimar.de/cms/medien/cg.html What You ll See Today What is OpenGL? Related Libraries OpenGL Command Syntax B. Azari http://www.uni-weimar.de/cms/medien/cg.html

More information

2 Transformations and Homogeneous Coordinates

2 Transformations and Homogeneous Coordinates Brief solutions to Exam in Computer Graphics Time and place: 08:00 3:00 Tuesday March 7, 2009, Gimogatan 4, sal Grades TD388: 3: 20pts; 4: 26pts; 5: 34pts. Glossary API Application Programmer s Interface.

More information

Input and Interaction. 1. Interaction. Chapter 3. Introduction: - We now turn to the development of interactive graphics programs.

Input and Interaction. 1. Interaction. Chapter 3. Introduction: - We now turn to the development of interactive graphics programs. Input and Interaction Chapter 3 Introduction: - We now turn to the development of interactive graphics programs. - Our discussion has three main parts First, we consider the variety of devices available

More information