Two-Dimensional Viewing

Slides:



Advertisements
Similar presentations
Computer Graphics CLIPPING.
Advertisements

Objectives Define Clipping Various clipping methods. Line clipping methods.
CMPE 466 COMPUTER GRAPHICS
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
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.
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)
Course Website: Computer Graphics 4: Viewing In 2D.
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 : Clipping
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,
2D Viewing and Projection
2 D viewing Prepared by Elizabeth Isaac DCS, RSET.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
CHAPTER 7 2D VIEWING CGMB214: Introduction to Computer Graphics.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
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.
1 King ABDUL AZIZ University Faculty Of Computing and Information Technology CS 454 Computer graphics Two Dimensional Viewing Dr. Eng. Farag Elnagahy
Now Playing: California Stars Billy Bragg & Wilco from Mermaid Avenue
2D Viewing. 2D viewing transformation is a mapping of world coordinate scene to device coordinates xw min xw max yw min yw max xv min xv max yv min yv.
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
2-Dimension Viewing and Clipping
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
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.
Windowing and clipping
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Two Dimensional Viewing
Objectives Introduce basic implementation strategies Clipping Scan conversion.
Computer Graphics 2 – Dimensional Viewing.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
OpenGL Geometric Transformations. glMatrixMode(GL_MODELVIEW);
2 DIMENSIONAL VIEWING Ceng 477 Introduction to Computer Graphics Fall Computer Engineering METU.
TWO-DIMENSIONAL VIEWING
Geometric Transformations
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Windows, Viewports, and Clipping
Three-Dimensional Viewing Jehee Lee Seoul National University.
Unit – IV 2D Viewing. 2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation,
10/19/04© University of Wisconsin, CS559 Fall 2004 Last Time Clipping –Why we care –Sutherland-Hodgman –Cohen-Sutherland –Intuition for Liang-Barsky Homework.
EEL Introduction to Computer Graphics
Implementation of a Renderer Consider Programs are processd by the system line & polygon, outside the view volume Efficiently Understanding of the implementation.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
2D Viewing.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 3 1.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
A.Aruna/Assistant Professor/SNSCE
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
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.
Chapter 71 Computer Graphics - Chapter 7 From Vertices to Fragments Objectives are: How your program are processed by the system that you are using, Learning.
Clipping.
Two-Dimensional Viewing Hearn & Baker Chapter 6
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Computer Graphics Viewing
2D Viewing & Clipping 한신대 류승택
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND CLIPPING
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
Two Dimensional Viewing and Clipping.
COMPUTER GRAPHICS Clipping
Presentation transcript:

Two-Dimensional Viewing Chapter 6 Two-Dimensional Viewing

The Viewing Pipeline Window A world-coordinate area selected for display. defines what is to be viewed Viewport An area on a display device to which a window is mapped. defines where it is to be displayed Viewing transformation The mapping of a part of a world-coordinate scene to device coordinates. A window could be a rectangle to have any orientation.

Two-Dimensional Viewing

The Viewing Pipeline

The Viewing Pipeline

Viewing Effects Zooming effects Panning effects Device independent Successively mapping different-sized windows on a fixed-sized viewports. Panning effects Moving a fixed-sized window across the various objects in a scene. Device independent Viewports are typically defined within the unit square (normalized coordinates)

Viewing Coordinate Reference Frame The reference frame for specifying the world-coordinate window. Viewing-coordinate origin: P0 = (x0, y0) View up vector V: Define the viewing yv direction

Window-to-Viewport Coordinate Transformation

Window-to-Viewport Coordinate Transformation

Workstation transformtion

Clipping Operations Clipping Clip window Applications of clipping Identify those portions of a picture that are either inside or outside of a specified region of space. Clip window The region against which an object is to be clipped. The shape of clip window Applications of clipping World-coordinate clipping

Clipping Operations Viewport clipping Types of clipping It can reduce calculations by allowing concatenation of viewing and geometric transformation matrices. Types of clipping Point clipping Line clipping Area (Polygon) clipping Curve clipping Text clipping Point clipping (Rectangular clip window)

Line Clipping Possible relationships between line positions and a standard rectangular clipping region Before clipping after clipping

Line Clipping Possible relationships Completely inside the clipping window Completely outside the window Partially inside the window Parametric representation of a line x = x1 + u(x2 - x1) y = y1 + u(y2 - y1) The value of u for an intersection with a rectangle boundary edge Outside the range 0 to 1 Within the range from 0 to 1

Cohen-Sutherland Line Clipping Region code A four-digit binary code assigned to every line endpoint in a picture. Numbering the bit positions in the region code as 1 through 4 from right to left.

Cohen-Sutherland Line Clipping Bit values in the region code Determined by comparing endpoint coordinates to the clip boundaries A value of 1 in any bit position: The point is in that relative position. Determined by the following steps: Calculate differences between endpoint coordinates and clipping boundaries. Use the resultant sign bit of each difference calculation to set the corresponding bit value.

Cohen-Sutherland Line Clipping The possible relationships: Completely contained within the window 0000 for both endpoints. Completely outside the window Logical and the region codes of both endpoints, its result is not 0000. Partially

Liang-Barsky Line Clipping Rewrite the line parametric equation as follows: Point-clipping conditions: Each of these four inequalities can be expressed as:

Liang-Barsky Line Clipping Parameters p and q are defined as

Liang-Barsky Line Clipping pk = 0, parallel to one of the clipping boundary qk < 0, outside the boundary qk >= 0, inside the parallel clipping boundary pk < 0, the line proceeds from outside to the inside pk > 0, the line proceeds from inside to outside

Liang-Barsky Line Clipping

Liang-Barsky Line Clipping Parameters u1 and u2 that define that part of the line lies within the clip rectangle The value of u1 : From outside to inside (pk < 0) The value of u2 : From inside to outside (pk > 0) If u1 > u2, the line is completely outside the clip window.

Liang-Barsky Line Clipping

Nicholl-Lee-Nicholl Line Clipping Compared to C-S and L-B algorithms NLN algorithm performs fewer comparisons and divisions. NLN can only be applied to 2D clipping. The NLN algorithm Clip a line with endpoints P1 and P2 First determine the position of P1 for the nine possible regions. Only three regions need be considered The other regions using a symmetry transformation Next determine the position of P2 relative to P1.

Nicholl-Lee-Nicholl Line Clipping

Nicholl-Lee-Nicholl Line Clipping

Nicholl-Lee-Nicholl Line Clipping

Nicholl-Lee-Nicholl Line Clipping To determine the region in which P2 is located Compare the slope of the line to the slopes of the boundaries of the clip region. Example: P1 is left of the clipping rectangle, P2 is in region LT.

Nonrectangular Clip Windows Algorithms based on parametric line equations can be extended Liang-Barsky method Modify the algorithm to include the parametric equations for the boundaries of the clip region Concave polygon-clipping regions Split into a set of convex polygons Apply parametric clipping procedures Circle or other curved-boundary clipping regions Lines can be clipped against the bounding rectangle

Splitting Concave Polygons Identify a concave polygon Calculating the cross product of successive edge vectors. If the z component of some cross product is positive while others have a negative, it is concave.

Splitting Concave Polygons Vector method Calculate the edge-vector cross product in a counterclockwise order. If any z component turns out to be negative The polygon is concave. Split it along the line of the first edge vector in the cross-product pair.

Splitting Concave Polygons Rotational method Proceeding counterclockwise around the polygon edges. Translate each polygon vertex Vk to the coordinate origin. Rotate in a clockwise direction so that the next vertex Vk+1 is on the x axis. If the next vertex, Vk+2, is below the x axis, the polygon is concave. Split the polygon along the x axis.

Splitting Concave Polygons

Polygon Clipping

Sutherland-Hodgeman Polygon Clipping Processing the polygon boundary as a whole against each window edge Processing all polygon vertices against each clip rectangle boundary in turn

Sutherland-Hodgeman Polygon Clipping Pass each pair of adjacent polygon vertices to a window boundary clipper There are four cases:

Sutherland-Hodgeman Polygon Clipping Intermediate output vertex list Once all vertices have been processed for one clip window boundary, it is generated. The output list of vertices is clipped against the next window boundary. It can be eliminated by a pipeline of clipping routine. Convex polygons are correctly clipped. If the clipped polygon is concave Split the concave polygon

Sutherland-Hodgeman Polygon Clipping v3 v2 v1

Weiler-Atherton Polygon Clipping Developed as a method for identifying visible surfaces It can be applied with arbitrary polygon-clipping region. Not always proceeding around polygon edges Sometimes follows the window boundaries For clockwise processing of polygon vertices For an outside-to-inside pair of vertices, follow the polygon boundary. For an inside-to-outside pair of vertices, follow the window boundary in clockwise direction.

Weiler-Atherton Polygon Clipping

Other Clipping Curve clipping Text clipping Use bounding rectangle to test for overlap with a rectangular clip window. Text clipping All-or-none string-clipping All-or-none character-clipping Clip the components of individual characters

Exterior Clipping Save the outside region Applications Multiple window systems The design of page layouts in advertising or publishing Adding labels or design patterns to a picture Procedures for clipping objects to the interior of concave polygon windows

Exterior Clipping