521493S Computer Graphics Exercise 1 (Chapters 1-3)

Similar documents
2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

Clipping Lines. Dr. Scott Schaefer

3D Rendering Pipeline (for direct illumination)

Rectangular Coordinates in Space

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Computer Graphics. The Two-Dimensional Viewing. Somsak Walairacht, Computer Engineering, KMITL

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

CSE328 Fundamentals of Computer Graphics

Unit 3 Transformations and Clipping

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Chapter 8: Implementation- Clipping and Rasterization

CS602 MCQ,s for midterm paper with reference solved by Shahid

Werner Purgathofer

Computer Graphics: Two Dimensional Viewing

+ b. From this we can derive the following equations:

More on Coordinate Systems. Coordinate Systems (3) Coordinate Systems (2) Coordinate Systems (5) Coordinate Systems (4) 9/15/2011

Section III: TRANSFORMATIONS

CSCI 4620/8626. Computer Graphics Clipping Algorithms (Chapter 8-5 )

CS Exam 1 Review Problems Fall 2017

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Computer Graphics: 7-Polygon Rasterization, Clipping

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Visible Surface Detection Methods

Drawing and Coordinate Systems

(Refer Slide Time: 00:02:02)

Today s class. Viewing transformation Menus Mandelbrot set and pixel drawing. Informationsteknologi

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations

CSCI 4620/8626. Coordinate Reference Frames

Drawing and Coordinate Systems

Intro to Modeling Modeling in 3D

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

CS488 2D Graphics. Luc RENAMBOT

8. Hidden Surface Elimination

Perspective Mappings. Contents

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

2D TRANSFORMATIONS AND MATRICES

2.3. Graphing Calculators; Solving Equations and Inequalities Graphically

4.5 VISIBLE SURFACE DETECTION METHODES

The Traditional Graphics Pipeline

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

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

QUADRATIC AND CUBIC GRAPHS

Topic #1: Rasterization (Scan Conversion)

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Part 3: 2D Transformation

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

The Traditional Graphics Pipeline

The Rectangular Coordinate System and Equations of Lines. College Algebra

From Vertices To Fragments-1

2D Viewing. Viewing Pipeline: Window-Viewport Transf.

CHAPTER 2 REVIEW COORDINATE GEOMETRY MATH Warm-Up: See Solved Homework questions. 2.2 Cartesian coordinate system

0. Introduction: What is Computer Graphics? 1. Basics of scan conversion (line drawing) 2. Representing 2D curves

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

Windows and Viewports. Windows and Viewports. Windows and Viewports. Windows and Viewports. CSC 706 Computer Graphics

Part IV. 2D Clipping

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

From 3D World to 2D Screen. Hendrik Speleers

UNIT 2 2D TRANSFORMATIONS

USING DUAL GRAPHICS VIEWS IN GEOGEBRA

Two-Dimensional Viewing. Chapter 6

Topic 0. Introduction: What Is Computer Graphics? CSC 418/2504: Computer Graphics EF432. Today s Topics. What is Computer Graphics?

UNIT -8 IMPLEMENTATION

Chapter 3. Sukhwinder Singh

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading.

The Traditional Graphics Pipeline

CS602- Computer Graphics Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring 2013 CS602- Computer Graphics

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Computer Graphics II

Viewing Transformation. Clipping. 2-D Viewing Transformation

MATHEMATICS FOR ENGINEERING TRIGONOMETRY

Graphing with a Graphing Calculator

EF432. Introduction to spagetti and meatballs

8. Hidden Surface Elimination

Hidden-Surface Removal.

Computer Graphics Viewing Objective

CSCI 4620/8626. The 2D Viewing Pipeline

f (Pijk ) V. may form the Riemann sum: . Definition. The triple integral of f over the rectangular box B is defined to f (x, y, z) dv = lim

Graphics and Interaction Rendering pipeline & object modelling

CHAPTER 1 Graphics Systems and Models 3

COMP30019 Graphics and Interaction Rendering pipeline & object modelling

Lecture outline. COMP30019 Graphics and Interaction Rendering pipeline & object modelling. Introduction to modelling

Computer Graphics: 8-Hidden Surface Removal

Computer Graphics. - Rasterization - Philipp Slusallek

EF432. Introduction to spagetti and meatballs

CEng 477 Introduction to Computer Graphics Fall 2007

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review.

Midterm Exam Fundamentals of Computer Graphics (COMP 557) Thurs. Feb. 19, 2015 Professor Michael Langer

COMP3421. Vector geometry, Clipping

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Clipping. Concepts, Algorithms for line clipping. 1 of 16. Andries van Dam. Clipping - 10/12/17

Viewing with Computers (OpenGL)

The Rendering Pipeline (1)

Chpt 1. Functions and Graphs. 1.1 Graphs and Graphing Utilities 1 /19

SE Mock Online Test 1-CG

Rational Numbers: Graphing: The Coordinate Plane

Transformation Pipeline

Transcription:

521493S Computer Graphics Exercise 1 (Chapters 1-3) 1. Consider the clipping of a line segment defined by the latter s two endpoints (x 1, y 1 ) and (x 2, y 2 ) in two dimensions against a rectangular clipping window (x min, y min ; x max, y max ). Show that only the endpoints are required to determine whether the line segment is not clipped, is partially visible, or is clipped out completely. Suppose that the line segment is between the points P 1 = (x 1, y 1 ) and P 2 = (x 2, y 2 ). We can use the endpoints of the line segment to determine where it resides in the window (x min, y min ; x max, y max ): If we create a line using parametric form: For x-axis we can solve t x : P(t) = (1 t)p 1 + tp 2, t [0, 1] t x = P 1x x P 1x P 2x We need to deal with horizontal and vertical line segments as special cases. We can check if we are in the line segment at the borders by evaluating t x (x min ) and t x (x max ). Y- axis can be checked similarly. By checking the available unclipped range of t using information from all the dimensions, we can determine if the line is fully clipped, partially clipped or completely unclipped. 1.1 Alternative solution We can solve y(x) from the known end points: 1

y = ax + b = y x x + b = y 2 y 1 x + b The unknown offset b can be solved by using any of the known points on the line. We use (x 1, y 1 ) here: Solving b from the above equation: Assigning b back to the original equation: Similarly x(y) can be solved: y 1 = y 2 y 1 x 1 + b b = y 1 y 2 y 1 x 1 y = y 2 y 1 x + y 1 y 2 y 1 x 1 x = y 2 y 1 y + x 1 y 2 y 1 y 1 We need to deal with horizontal and vertical line segments as special cases. We can find the intersections with the sides of the window by substituting y = y max, y = y min, x = x max and x = x min (the equations for the sides of the window) into the above equations. We can check the locations of the points of intersection to determine if they are on the line segment or only on the line of which it is part. 2. To avoid flicker, the memory in a frame buffer must be fast enough to allow the display to be refreshed at a rate sufficiently high. A typical workstation display can have a resolution of 1280 x 1024 pixels. If it is refreshed 72 times per second, how fast must the memory be? That is, how much time can we take to read one pixel from memory? What is this number for a 480x640 display that operates at 60 Hz but is interlaced? We have to process 1280 x 1024 x 72 pixels/sec. If we process each successively, there is only about 10 nanoseconds to process each. For a 480 x 640 interlaced display operating at 60 Hz we must process only 480 x 640 x 30 pixels/sec which gives us about 109 nanoseconds to process each pixel. 3. A fundamental operation in graphics system is to map a point (x, y), which lies within a clipping rectangle, to a point (x s, y s ), which lies in the viewport of a window on the screen. Assume that the two rectangles are defined by OpenGL function calls. glviewport(u, v, w, h); gluortho2d(x_min, x_max, y_min, y_max); Find the mathematical equations that map (x, y) into (x s, y s ). 2

We can solve this problem separately in the x and y directions. The transformation is linear, that is x s = ax + b, y s = cy + d. We must maintain proportions, so that x s in the same relative position in the viewport as x is in the window, hence Likewise x x min = x s u x max x min w, x s = u + w x x min, x max x min y s = v + h y y min. y max y min 4. Devise a test for convexity of two-dimensional polygon. Consider the lines defined by the sides of the polygon. We can assign a direction for each of these lines by traversing the vertices in a counter-clockwise order. One very simple test is obtained by noting that any point inside the object is on the left of each of these lines. Thus, if we substitute the point into the equation for each of the lines (ax + by + c), we should always get the same sign. 5. The mapping from a point in three-dimensional world coordinates to one in screen coordinates is well defined. What problems exist for inverting the mapping? i.e. Trying to map screen coordinates to world coordinates. 3

The most significant problem is that going from three dimensions to two dimensions we lose one dimension. Therefore each point in the screen map to some kind of line in the world coordinates instead of a single coordinate. Additional problems are that multiple three-dimensional lines may map to the same screen coordinate even when the coordinates are not integers. There may also be points in the screen that do not map to any valid positions in the world coordinates. For example if the whole world is mapped to a rectangle at the center of the screen, inverse mapping will not exist for pixels outside the rectangle at all. 6. Suppose a user is running a program using a GLUT window to draw OpenGL graphics. The window size is 400 x 300 pixels. An orthogonal projection of the scene is setup as follows: glviewport(0, 0, 400, 300); gluortho2d(0, 400, 0, 300); There are four circles in the scene that user can select with a mouse. As each circle can be defined as a triplet (x, y, r) where x and y are the coordinates and r is the circle radius, the four circles are expressed by c 1 = (100, 100, 50) c 2 = (300, 100, 50), c 3 = (100, 200, 50), c 4 = (300, 200, 50). When user selects his favorite circle, the GLUT callback function for mouse pointer position reports that the mouse is at coordinates (110, 110). What circle (if any) does the user select? Please also explain your answer. glviewport and gluortho2d create an orthographic view of the scene with visible size of 400 x 300. Also the actual window is of the same size so no scaling or stretching happens. Therefore a circle c 1 centered at (100,100) with radius of (50) is drawn centered as the same OpenGL screen coordinates. However, there is a difference between GLUT coordinates and OpenGL coordinates in the screen. GLUT passes down coordinates that come from the underlying windowing system as relative coordinates to the window position where the origin is at top left, x-axis grows to the right and y- axis down. In OpenGL, using presented setup and no additional transformations, the origin is at bottom left with y-axis pointing up. This means that when reported mouse pointer is at (110, 110), the position in the scene is (110, (300 1) 110) that equals (110, 189). This point is in the area of circle c 3 = (100, 200, 50) 4

7. Double buffering is used to reduce flickering of the screen caused by simultaneously drawing objects while the screen is displayed. What is the best time to flip the buffers to minimize any visual problems caused by the screen update? And why? During vertical retraces. Suppose that we have a fast computer that can render 300 frames per second. Screen of this computer is physically updated at 60 Hz. This means that we can render a completely different scene and show it 5 times during one screen update. This can cause a visual tearing effect as a set of lines come from a different image than ones above it. Quickly horizontally moving objects have parts of them shown at different positions during the same screen update. By limiting updates to one per screen refresh and refreshing the screen during vertical retrace period, no visible artifacts can be seen. 5