Set the Viewport. Set the Viewport Clipping. Set the Viewport. Set the Viewport. Set the Viewport. Resizing the Viewport W = H

Similar documents
Set the Viewport Clipping. Computer Graphics CSC470 1

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

From 3D World to 2D Screen. Hendrik Speleers

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

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

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

CHAPTER 3. More Drawing Tools.

3D Rendering Pipeline (for direct illumination)

Clipping Points Consider a clip window which is rectangular in shape. P(x, y) is a point to be displayed.

Clipping Lines. Dr. Scott Schaefer

Graphics and Visualization

Chapter 8: Implementation- Clipping and Rasterization

Clipping and Intersection

From Vertices To Fragments-1

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

Two-Dimensional Viewing. Chapter 6

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

Sung-Eui Yoon ( 윤성의 )

Clipping Algorithms; 8-5. Computer Graphics. Spring CS4815

Clipping and Scan Conversion

Examples. Clipping. The Rendering Pipeline. View Frustum. Normalization. How it is done. Types of operations. Removing what is not seen on the screen

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Realtime 3D Computer Graphics Virtual Reality

Illumination Models III: Ray Tracing (View Dependent Global Illumination)

COMPUTATIONAL GEOMETRY

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

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

Part IV. 2D Clipping

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

Viewing Transformation. Clipping. 2-D Viewing Transformation

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

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Computer Graphics Viewing Objective

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

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

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

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

CS 450: COMPUTER GRAPHICS REVIEW: CLIPPING SPRING 2015 DR. MICHAEL J. REALE

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

Binghamton University. EngiNet. Thomas J. Watson. School of Engineering and Applied Science. Computer Graphics. State University of New York.

CS452/552; EE465/505. Clipping & Scan Conversion

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

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

Topics. From vertices to fragments

Computer Graphics Geometry and Transform

Introduction to Computer Graphics 5. Clipping

CS 325 Computer Graphics

Computer Graphics (CS 543) Lecture 10 (Part 1): 3D Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Computer Graphics: Two Dimensional Viewing

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

COMP3421. Vector geometry, Clipping

Unit 6: Connecting Algebra and Geometry Through Coordinates

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

MODULE - 9. Subject: Computer Science. Module: Line Clipping. Module No: CS/CGV/9

Unit 3 Transformations and Clipping

Windowing And Clipping (14 Marks)

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

Introduction to Computer Graphics with OpenGL/GLUT

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

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

Part 3: 2D Transformation

1 Attempt any three of the following: 1 5 a. What is Computer Graphics? How image is to be display on Video Display Device?

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

Computer Graphics 7: Viewing in 3-D

CS 4204 Computer Graphics

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

.(3, 2) Co-ordinate Geometry Co-ordinates. Every point has two co-ordinates. Plot the following points on the plane. A (4, 1) D (2, 5) G (6, 3)

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

Geometry Reasons for Proofs Chapter 1

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

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

Input and Interaction

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

What is Clipping? Why do we Clip? Lecture 9 Comp 236 Spring Clipping is an important optimization

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 Graphics Pipeline. Interactive Computer Graphics. The Graphics Pipeline. The Graphics Pipeline. The Graphics Pipeline: Clipping

1999, Denis Zorin. Ray tracing

Lesson 21: Surface Area

Computer Graphics: 7-Polygon Rasterization, Clipping

I can position figures in the coordinate plane for use in coordinate proofs. I can prove geometric concepts by using coordinate proof.

Today. CS-184: Computer Graphics. Lecture #10: Clipping and Hidden Surfaces. Clipping. Hidden Surface Removal

Computer Graphics Geometry and Transform

Chapter 1. Linear Equations and Straight Lines. 2 of 71. Copyright 2014, 2010, 2007 Pearson Education, Inc.

Scan Conversion of Polygons. Dr. Scott Schaefer

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

CS 543: Computer Graphics. Rasterization

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

The statement implies that any three intersection points of two distinct planes lie on a line.

Answer Key: Three-Dimensional Cross Sections

Einführung in Visual Computing

Three Dimensional Geometry. Linear Programming

heptagon; not regular; hexagon; not regular; quadrilateral; convex concave regular; convex

Implicit Generalized Cylinders using Profile Curves

Geometry Practice. 1. Angles located next to one another sharing a common side are called angles.

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

FORMULAS to UNDERSTAND & MEMORIZE

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

Transcription:

To draw an undistorted version of the data in a viewport, you need to ensure the viewport and the window have the same aspect ratio. i.e. W H window window W = H viewport viewport Computer Graphics CSC470 1 Computer Graphics CSC470 2 Recall, if the aspect ratio of a rectangle is less than 0, the rectangle is taller than wide. E.g. W/H = 3/5 If the aspect ratio is greater than 0, the rectangle is wider than tall. E.g. W/H = 5/3 a) R > W/H (where R is the aspect ratio of the world window) If the world window is flatter than the screen window, there will be unused space above and/or below. The width of the world window will be mapped to the entire width of the screen window. setviewport(0,w,0,w/r); Computer Graphics CSC470 3 Computer Graphics CSC470 4 b) R < W/H (where R is the aspect ratio of the world window) If the world window is taller than the screen window, there will be unused space on the sides. The height of the world window will be mapped to the entire height of the screen window. setviewport(0,h*r,0,h); Resizing the Viewport In a windows environment, the user may resize the screen window and therefore affect the viewport while the program is running. When this occurs, you will want to be able to ensure redrawing of the image occurs within the same aspect ratio. Computer Graphics CSC470 5 Computer Graphics CSC470 6 1

Resizing the Viewport OpenGL provides a resize event that is called when the user resizes a window. This can be linked to your own resizing function. glutreshapefunc( myreshape); This works the same as for the glutmousefunc and glutkeyboardfunc If you don t run a glviewport after a window resize, the glviewport defaults to the window coordinates. Resizing the Viewport void myreshape(glsizei W, GLsizei H) { //R is the aspect ratio of the world window if(r > W/H) //use global window aspect ratio setviewport(0, W, 0, W/R); else setviewport(0, H*R, 0, H); } -example322.cpp Computer Graphics CSC470 7 Computer Graphics CSC470 8 is fundamental in Computer Graphics. It means to discard parts of the image that are not in the viewport. OpenGL takes care of clipping for you, but you still need to understand how it works. : Remove points outside a region of interest. Want to discard everything that s outside of our window... Primitives: point, line-segment, and polygon. Point clipping: Remove points outside window. A point is either entirely inside the region or not. Line-segment clipping: Remove portion of line segment outside window. Line segments can straddle the region boundary. Polygon clipping: Remove portion of polygon outside window Computer Graphics CSC470 9 1. Trivially Accept or Reject if both ends of a line lie inside the window (e.g. AB) then the line can be trivially accepted as it doesn t need to be clipped. if both ends of a line lie outside the window (e.g. CD) then the line can be trivially rejected as all of it is clipped. Testing for Trivial Acceptance or Rejection Divide the window and surrounding areas and assign codes. Left,Above,Right,Below Computer Graphics CSC470 11 Computer Graphics CSC470 12 2

Testing for Trivial Acceptance or Rejection 1. Divide the window and surrounding areas and assign codes. 2. Assign the code to the end points of the line. P 1 = TTFF, P 2 = FFFF Trivially Accept if both points have the code FFFF P Trivially Reject if both points have a 1 T in the same position e.g. both P 2 points are left, above, right or below the window. when there is neither trivial accept nor reject. A line that cannot be trivial accepted or rejected will have one end point inside the window and one outside, or; Will have one endpoint on one side and the other endpoint on the other so that the line crosses the window. These lines need to be chopped at the window border intersections. Computer Graphics CSC470 13 Computer Graphics CSC470 14 Line Example Clip a line against 1 edge of the viewport What do we know? Similar triangles A / B = C / D B = (x2 -x1) A = (y2 -y1) C = (y1 -ymax) D = BC / A (x, y ) = (x1 -D, ymax) C A (x1, y1) (x, y )??? D (x2, y2) B We need to determine where A is. its x coordinate is window.right its y coordinate can be calculated using similar triangles.. d = dely e delx Computer Graphics CSC470 15 Computer Graphics CSC470 16 We need to determine where A is. e = p1.x W.right delx = p2.x p1.x; dely = p2.y p1.y; d = e/delx * dely; p1.y += (W.right p1.x) * dely/delx Computer Graphics CSC470 17 Computer Graphics CSC470 18 3

Perform the Cohen-Sutherland for the following lines: (15,15) (20,20) (60,90) (90,90) (55,65) (110,120) what lines are you left with? 140 120 100 80 60 40 20 TTFF FTFF FTTF 20, 20 15, 15 110, 120 60, 90 90, 90 TFFF FFFF FFTF 55, 65 TFFT FFFT FFTT 0 0 20 40 60 80 100 120 140 160 Computer Graphics CSC470 19 Computer Graphics CSC470 20 (15,15) TFFT (20,20) TFFT (reject) (60,90) FFFF (90,90) FFFF (accept) (55,65) FFFF (110,120) FTTF (keep and clip) (55,65) (110,120) (clip right point on top border of right) For top border y = 100, therefore find the point on the line where y = 100. Use y = mx + c and solve for y = 100; m = 1, c = 10. x = 90 The line is now (55,65)(90,100) 60, 90 90, 90 55, 65 110, 120 Computer Graphics CSC470 21 Computer Graphics CSC470 22 3D Line-clip Algorithm Polygon Not as simple as line segment clipping a line segment yields at most one line segment a polygon can yield multiple polygons Half-space now lies on one side of a plane. Implicit formula for plane in 3D is same as that for line in 2D. Parametric formula for line to be clipped is unchanged. Use 6-bit outcodes When needed, clip line segment against planes However, clipping a convex polygon can yield at most one other polygon Computer Graphics CSC470 24 4

Polygons (1) Step by step example of polygon clipping Computer Graphics CSC470 25 Computer Graphics CSC470 26 Pipeline of Polygons Three dimensions: add front and back clippers Computer Graphics CSC470 27 5