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

Similar documents
From Vertices To Fragments-1

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

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

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

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

Clipping Lines. Dr. Scott Schaefer

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

3D Rendering Pipeline (for direct illumination)

Part IV. 2D Clipping

Two-Dimensional Viewing. Chapter 6

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

Chapter 8: Implementation- Clipping and Rasterization

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Computer Graphics: Two Dimensional Viewing

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

Realtime 3D Computer Graphics Virtual Reality

Topics. From vertices to fragments

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI

Lecture 7 of 41. Viewing 4 of 4: Culling and Clipping Lab 1b: Flash Intro

Computer Graphics Viewing Objective

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

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

Unit 3 Transformations and Clipping

Introduction to Computer Graphics 5. Clipping

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

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

Part 3: 2D Transformation

1. Create a map of the layer and attribute that needs to be queried

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

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

Dgp _ lecture 2. Curves

Computer Graphics II

The Rectangular Problem

SE Mock Online Test 1-CG

Points and lines. x x 1 + y 1. y = mx + b

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

Two Dimensional Viewing

Graphics (Output) Primitives. Chapters 3 & 4

CSCI 4620/8626. Coordinate Reference Frames

A Comprehensive Introduction to SolidWorks 2011

Manipal Institute of Technology Manipal University Manipal

Creating and editing vector maps

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

From 3D World to 2D Screen. Hendrik Speleers

CS 591B Lecture 9: The OpenGL Rendering Pipeline

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

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

FlexMLS Maps Quick Reference Guide

Assignment Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Course Title: Computer Graphics Course no: CSC209

Computer Graphics: 7-Polygon Rasterization, Clipping

Rasteriza2on and Clipping

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

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

Z- Buffer Store the depth for each pixel on the screen and compare stored value with depth of new pixel being drawn.

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

(Refer Slide Time: 00:02:00)

The University of Calgary

Grade Common Core Math

form are graphed in Cartesian coordinates, and are graphed in Cartesian coordinates.

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

How to create shapes. Drawing basic shapes. Adobe Photoshop Elements 8 guide

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

Roll No. : Invigilator's Signature :.. GRAPHICS AND MULTIMEDIA. Time Allotted : 3 Hours Full Marks : 70

Generating Vectors Overview

CATIA V5 Parametric Surface Modeling

CS 325 Computer Graphics

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Introduction p. 1 Java Features p. 2 Java Expansion p. 4 Getting, Setting Up, and Using Java p. 5 The Java Language p. 5 Java Swing Components p.

How to create a basic Orienteering map with Google Earth

End-Term Examination

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

Points and lines, Line drawing algorithms. Circle generating algorithms, Midpoint circle Parallel version of these algorithms

1.1 - Functions, Domain, and Range

Culling. Computer Graphics CSE 167 Lecture 12

LAMC Advanced Circle October 9, Oleg Gleizer. Warm-up

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY CS2401 COMPUTER GRAPHICS QUESTION BANK

Full Search Map Tab. This map is the result of selecting the Map tab within Full Search.

Computer Science 474 Spring 2010 Viewing Transformation

Class IX Mathematics (Ex. 3.1) Questions

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

COMPUTER AIDED ENGINEERING DESIGN (BFF2612)

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

Design and Communication Graphics

CPSC / Scan Conversion

4. If you are prompted to enable hardware acceleration to improve performance, click

(Refer Slide Time 03:00)

EF432. Introduction to spagetti and meatballs

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

Clipping and Scan Conversion

CS337 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics. Bin Sheng Representing Shape 9/20/16 1/15

EF432. Introduction to spagetti and meatballs

Adobe illustrator Introduction

15. Clipping. Projection Transformation. Projection Matrix. Perspective Division

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

(Refer Slide Time: 00:03:51)

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

Undo Button Clicking this tool will undo the last action. Clicking on this tool multiple times will undo all subsequent changes that were made.

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Describing Shapes. Constructing Objects in Computer Graphics 1/15

USER S MANUAL Software Usage Agreement Registered Trademarks Notes on this Manual Disclaimer

Transcription:

Computer Graphics Spring 2016-2017

Outline Clipping Algorithms; 8-5 1 Clipping Algorithms; 8-5

Announcements Mid-term: Week07??

Clipping: Introduction It is common for a region to be defined so that only graphics inside (or outside) the region are drawn Since vertices, lines and simple polygons (made up of straight lines) make up so much of our graphics scenes it is important that we be able to rapidly decide how much if any of these lines to draw This process is called clipping Although we will only work with 2-D rectangular windows clipping algorithms are not limited to this case We can have regions with non-linear boundaries such as circles, ellipses, spheres, as well as spline curves and spline surfaces Point clipping is easiest: for a bounding box of (x bl, y bl ) to (x ur, y ur ) we only select the point (x, y) if x bl x x ur y bl y y ur

Clipping: Introduction It is common for a region to be defined so that only graphics inside (or outside) the region are drawn This process is called clipping Although we will only work with 2-D rectangular windows clipping algorithms are not limited to this case We can have regions with non-linear boundaries such as circles, ellipses, spheres, as well as spline curves and spline surfaces Point clipping is easiest: for a bounding box of (x bl, y bl ) to (x ur, y ur ) we only select the point (x, y) if x bl x x ur y bl y y ur

Clipping: Introduction It is common for a region to be defined so that only graphics inside (or outside) the region are drawn This process is called clipping Although we will only work with 2-D rectangular windows clipping algorithms are not limited to this case We can have regions with non-linear boundaries such as circles, ellipses, spheres, as well as spline curves and spline surfaces Point clipping is easiest: for a bounding box of (x bl, y bl ) to (x ur, y ur ) we only select the point (x, y) if x bl x x ur y bl y y ur

Clipping: Introduction It is common for a region to be defined so that only graphics inside (or outside) the region are drawn This process is called clipping Although we will only work with 2-D rectangular windows clipping algorithms are not limited to this case We can have regions with non-linear boundaries such as circles, ellipses, spheres, as well as spline curves and spline surfaces Point clipping is easiest: for a bounding box of (x bl, y bl ) to (x ur, y ur ) we only select the point (x, y) if x bl x x ur y bl y y ur

Clipping: Introduction It is common for a region to be defined so that only graphics inside (or outside) the region are drawn This process is called clipping Although we will only work with 2-D rectangular windows clipping algorithms are not limited to this case We can have regions with non-linear boundaries such as circles, ellipses, spheres, as well as spline curves and spline surfaces Point clipping is easiest: for a bounding box of (x bl, y bl ) to (x ur, y ur ) we only select the point (x, y) if x bl x x ur y bl y y ur

Line Clipping; 6-7 (x, y ) ur ur L 2 L 6 L 3 L 5 L 1 (x, y ) bl bl Clipping window L 4

Line Clipping Clipping Algorithms; 8-5 (x, y ) ur ur (x, y ) bl bl Clipping window

Line Clipping Clipping Algorithms; 8-5 Line clipping algorithms are greatly sped up by lines either being entirely inside the clipping rectangle or entirely outside So lines L 1, L 2 or L 3 previously will be easier for almost all clipping algorithms than L 4, L 5 or L 6 Contrast this with culling, the process of eliminating from consideration those objects that are entirely outside the window; done prior to clipping Lines L 5 and L 6 will prove hardest and most time consuming to clip

An Inefficient Line Clipper Use parametric representation of a line between start p = (x s, y s ) and end q = (x e, y e ) x = x s + u(x e x s ) y = y s + u(y e y s ), 0 u 1 (or,u [0, 1]) What does it mean if u [0, 1] We can find where this line crosses the west side of the rectangle (x = x bl ) by solving for u in x bl = x s + u(x e x s ) u = (x bl x s )/(x e x s ) The line can cross western border only if u [0, 1] If u [0, 1] we can test one end point against x bl e.g. L 2 If u [0, 1] we can find value of y = y at x = x bl and we clip off portion outside Repeat for other three sides

To each endpoint assign a region code (outcode) that codes which of the 8 regions with respect to clip region that point is Code is a 4-bit value c = b 4 b 3 b 2 b 1 : if x < x bl (left outside) then set b 1 if x > x ur (right outside) then set b 2 if y < y bl (below outside) then set b 3 if y > y ur (above outside) then set b 4 A point is in clipping region if and only if code c = 0000 These can be set in a (marginally) more efficiently way by, for example, setting b 2 to sign bit of x ur x Not all 16 cases can occur: a point can t be both left and right of window, but can be neither (if x bl x x ur )

What do we do with this information? Look at codes c s and c e for start and end points of line using bitwise operators, or and and Any lines completely enclosed in clipping region have code 0000; using bitwise-or: c s c e == 0 Any line with 1 in same position must be outside; using bitwise-and: c s &c e > 0 For remaining cases we need to consider each of four borders in turn, compute intersection points with them, clip off the part outside and re-test if line is entirely in one region

What do we do with this information? Look at codes c s and c e for start and end points of line using bitwise operators, or and and Any lines completely enclosed in clipping region have code 0000; using bitwise-or: c s c e == 0 Any line with 1 in same position must be outside; using bitwise-and: c s &c e > 0 For remaining cases we need to consider each of four borders in turn, compute intersection points with them, clip off the part outside and re-test if line is entirely in one region

What do we do with this information? Look at codes c s and c e for start and end points of line using bitwise operators, or and and Any lines completely enclosed in clipping region have code 0000; using bitwise-or: c s c e == 0 Any line with 1 in same position must be outside; using bitwise-and: c s &c e > 0 For remaining cases we need to consider each of four borders in turn, compute intersection points with them, clip off the part outside and re-test if line is entirely in one region

What do we do with this information? Look at codes c s and c e for start and end points of line using bitwise operators, or and and Any lines completely enclosed in clipping region have code 0000; using bitwise-or: c s c e == 0 Any line with 1 in same position must be outside; using bitwise-and: c s &c e > 0 For remaining cases we need to consider each of four borders in turn, compute intersection points with them, clip off the part outside and re-test if line is entirely in one region

What do we do with this information? Look at codes c s and c e for start and end points of line using bitwise operators, or and and Any lines completely enclosed in clipping region have code 0000; using bitwise-or: c s c e == 0 Any line with 1 in same position must be outside; using bitwise-and: c s &c e > 0 For remaining cases we need to consider each of four borders in turn, compute intersection points with them, clip off the part outside and re-test if line is entirely in one region To compute y corresponding to x = x bl or x = x ur y = y s + m(x x s )

What do we do with this information? Look at codes c s and c e for start and end points of line using bitwise operators, or and and Any lines completely enclosed in clipping region have code 0000; using bitwise-or: c s c e == 0 Any line with 1 in same position must be outside; using bitwise-and: c s &c e > 0 For remaining cases we need to consider each of four borders in turn, compute intersection points with them, clip off the part outside and re-test if line is entirely in one region To compute x corresponding to y = y bl or y = y ur x = x s + 1 m (y y s)

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally...

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 2

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 2

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 2

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 2 p 2

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 2 p 2

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 1 p 2 p 2

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 1 p 2 p 2

Assume borders are processed in order left, right, bottom, top No points west of left border Point p 2 is to east of right border so we clip it, but only to p 2 Point p 1 is south of bottom border so we clip it at p 1 Point p 2 now gets considered and we get, finally... p 1 p 1 p 2 p 2

Analysis of Cohen-Sutherland Alg. In general, the Cohen-Sutherland algorithm is not optimal In picture to right, if clipping order is north, west, east, south then much wasted work in the form of multiple shortenings of the line is performed Also, each C-S shortening requires a floating point division or multiplication (to solve line intersection)