10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.

Slides:



Advertisements
Similar presentations
CS 376 Introduction to Computer Graphics 02 / 02 / 2007 Instructor: Michael Eckmann.
Advertisements

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 30, D Clipping 1/14 Clipping (pages , )
Computer Graphics 4: Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling By:Kanwarjeet Singh.
Larry F. Hodges (modified by Amos Johnson) 1 Design of Line, Circle & Ellipse Algorithms.
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
3/2/04© University of Wisconsin, CS559 Spring 2004 Last Time General Perspective –Methods for specifying the view volume As a set of clip planes As a field.
David Breen, William Regli and Maxim Peysakhov
Dr. Scott Schaefer Clipping Lines. 2/94 Why Clip? We do not want to waste time drawing objects that are outside of viewing window (or clipping window)
1 Clipping. 2 Transformation Sequence X Y Z X Y Z X Y Z X Y Z Object Coords. Eye Coords. Clip Coords. Normalized Device Coords. Screen Coords. Implementation:
Two-Dimensional Viewing Jehee Lee Seoul National University.
Computer Graphics Viewing.
Viewing & Clipping In 2D. 2 of 44 Contents Windowing Concepts Clipping –Introduction –Brute Force –Cohen-Sutherland Clipping Algorithm Area Clipping –Sutherland-Hodgman.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
CS5500 Computer Graphics © Chun-Fa Chang, Spring 2007 CS5500 Computer Graphics May 3, 2007.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
CS 325 Introduction to Computer Graphics 03 / 03 / 2010 Instructor: Michael Eckmann.
Clipping Apart from clipping to the view volume, clipping is a basic operation in many other algorithms –Breaking space up into chunks –2D drawing and.
Dr. S.M. Malaek Assistant: M. Younesi
Scan Conversion Line and Circle
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Objectives Introduce basic implementation strategies Clipping Scan conversion.
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)
College of Computer and Information Science, Northeastern UniversityOctober 12, CS G140 Graduate Computer Graphics Prof. Harriet Fell Spring 2006.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
10/26/04© University of Wisconsin, CS559 Fall 2004 Last Time Drawing lines Polygon fill rules Midterm Oct 28.
10/15/02 (c) 2002 University of Wisconsin, CS559 Last Time Clipping.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
MIDPOINT CIRCLE & ELLIPSE GENERARTING ALGORITHMS
10/15/02 (c) 2002 University of Wisconsin, CS559 Who Am I? Prof Stephen Chenney These notes will be online after the lecture – in fact they’re online already.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
EEL Introduction to Computer Graphics
CS 325 Introduction to Computer Graphics 02 / 03 / 2010 Instructor: Michael Eckmann.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Week 4 Functions and Graphs. Objectives At the end of this session, you will be able to: Define and compute slope of a line. Write the point-slope equation.
Clipping Primitives. Clipping line Clipping rectangle: – x min to x max – y min to y max A point (x,y) lies within a clip rectangle and thus displayed.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
A.Aruna/Assistant Professor/SNSCE
Institute for Visualization and Perception Research 1 © Copyright 2000 Haim Levkowitz Raster graphics alg’s for drawing 2D primitives Points of view Application.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Computer Graphics CC416 Week 13 Clipping.
Concepts, Algorithms for line clipping
(c) 2002 University of Wisconsin, CS559
Introduction to Graphing
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Fall 2004
(c) 2002 University of Wisconsin, CS559
© University of Wisconsin, CS559 Fall 2004
Chapter 3 Graphics Output Primitives
Clipping Clipping Sutherland-Hodgman Clipping
Where We Stand At this point we know how to: Next thing:
COMPUTER GRAPHICS Clipping
Presentation transcript:

10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework 4, due Oct 26 in class

10/19/04© University of Wisconsin, CS559 Fall 2004 Midterm Info October 28 in class All material listed in online “to-know” list Allowed: –Pencil/pen, ruler –One sheet of letter (standard) sized paper, with anything on it, both sides Nothing to increase the surface area Not allowed: –Calculator, anything else

10/19/04© University of Wisconsin, CS559 Fall 2004 Today Liang-Barsky Details Weiler-Atherton clipping algorithm Drawing points and lines

10/19/04© University of Wisconsin, CS559 Fall 2004 Liang-Barsky Intuition To be inside the clip region, you must have entered every clip edge before you have left any clip edge Enter Leave Enter Leave Enter Leave

10/19/04© University of Wisconsin, CS559 Fall 2004 When are we Inside? We want parameter values that are inside all the clip planes Last parameter value to enter is the start of the visible segment First parameter value to leave is the end of the visible segment If we leave some clip plane before we enter another, we cannot see any part of the line –First to leave will be before last to enter All this leads to an algorithm – Liang-Barsky

10/19/04© University of Wisconsin, CS559 Fall 2004 Liang-Barsky Sub-Tasks 1.Find parametric intersection points –Parameter values where line crosses each clip edge/plane 2.Find entering/leaving flags –For every clip edge/plane, are either entering or leaving 3.Find last parameter to enter, and first one to leave –Check that enter before leave 4.Convert these into endpoints of clipped segment

10/19/04© University of Wisconsin, CS559 Fall Parametric Intersection Segment goes from (x 1,y 1 ) to (x 2,y 2 ): Rectangular clip region with x min, x max, y min, y max Infinite line intersects rectangular clip region edges when: where

10/19/04© University of Wisconsin, CS559 Fall Entering or Leaving? When p k <0, as t increases line goes from outside to inside – entering When p k >0, line goes from inside to outside – leaving When p k =0, line is parallel to an edge –Special case: one endpoint outside, no part of segment visible, otherwise, ignore this clip edge and continue

10/19/04© University of Wisconsin, CS559 Fall 2004 Find Visible Segment ts Last parameter is enter is t small =max(0, entering t’s) First parameter is leave is t large =min(1, leaving t’s) If t small >t large, there is no visible segment If t small <t large, there is a line segment –Compute endpoints by substituting t values into parametric equation for the line segment Improvement (and actual Liang-Barsky): –compute t’s for each edge in turn (some rejects occur earlier like this)

10/19/04© University of Wisconsin, CS559 Fall 2004 General Liang-Barsky Liang-Barsky works for any convex clip region –E.g. Perspective view volume in world or view coordinates Require a way to perform steps 1 and 2 1.Compute intersection t for all clip lines/planes 2.Label them as entering or exiting Near Far Left Right

10/19/04© University of Wisconsin, CS559 Fall 2004 In View Space For Project 2, you need to clip edges to a view frustum in world space Situation is: eye, e frustum x right x left x1x1 x2x2

10/19/04© University of Wisconsin, CS559 Fall 2004 First Step Compute inside/outside for endpoints of the line segment –Determine which side of each clip plane the segment endpoints lie –Use the cross product –What do we know if (x 1 - e)  (x left - e) > 0 ? –Other cross products give other information What can we say if both segment endpoints are outside one clip plane? –Stop here if we can, otherwise…

10/19/04© University of Wisconsin, CS559 Fall 2004 Finding Parametric Intersection Left clip edge: x = e + (x left - e) t Line: x = x 1 + (x 2 - x 1 ) s Solve simultaneous equations in t and s: Use endpoint inside/outside information to label as entering or leaving Now we have general Liang-Barsky case

10/19/04© University of Wisconsin, CS559 Fall 2004 General Clipping Liang-Barsky can be generalized to clip line segments to arbitrary polygonal clip regions –Consider clip edges as non-infinite segments –Look at all intersecting ts between 0 and 1 Clipping general polygons against general clip regions is quite hard: Weiler-Atherton algorithm –Start with polygons as lists of vertices –Replace crossing points with vertices –Double all edges and form linked lists of edges –Adjust links at crossing vertices –Enumerate polygon patches

10/19/04© University of Wisconsin, CS559 Fall 2004 Weiler-Atherton – Form Lists Original Polygons Double Linked Lists - outside and inside lists

10/19/04© University of Wisconsin, CS559 Fall 2004 Weiler-Atherton – Find Crossings Crossing vertices added – links re-written

10/19/04© University of Wisconsin, CS559 Fall 2004 Weiler-Atherton – Enumerate “Not clip not poly”“Clip not Poly” “Clip and Poly” Every link used once “Poly not Clip”

10/19/04© University of Wisconsin, CS559 Fall 2004 Where We Stand At this point we know how to: –Convert points from local to screen coordinates –Clip polygons and lines to the view volume Next thing: –Determine which pixels to fill for any given point, line or polygon

10/19/04© University of Wisconsin, CS559 Fall 2004 Drawing Points When points are mapped into window coordinates, they could land anywhere – not just at a pixel center Solution is the simple, obvious one –Map to window space –Fill the closest pixel –Can also specify a radius – fill a square of that size, or fill a circle Square is faster What function are we sampling with?

10/19/04© University of Wisconsin, CS559 Fall 2004 Drawing Lines Task: Decide which pixels to fill (samples to use) to represent a line We know that all of the line lies inside the visible region (clipping gave us this!) Issues: –If slope between -1 and 1, one pixel per column. Otherwise, one pixel per row –Constant brightness? Lines of the same length should light the same number of pixels (we normally ignore this) –Anti-aliasing? (Getting rid of the “jaggies”) –Sampling theory?

10/19/04© University of Wisconsin, CS559 Fall 2004 Line Drawing Algorithms Consider lines of the form y=m x + c, where m=  y/  x, 0<m<1, integer coordinates –All others follow by symmetry, modify for real numbers Variety of slow algorithms (Why slow?): –step x, compute new y at each step by equation, rounding: –step x, compute new y at each step by adding m to old y, rounding:

10/19/04© University of Wisconsin, CS559 Fall 2004 Bresenham’s Algorithm Overview Aim: For each x, plot the pixel whose y-value is closest to the line Given (x i,y i ), must choose from either (x i +1,y i +1) or (x i +1,y i ) Idea: compute a decision variable –Value that will determine which pixel to draw –Easy to update from one pixel to the next Bresenham’s algorithm is the midpoint algorithm for lines –Other midpoint algorithms for conic sections (circles, ellipses)