2D Viewing.

Slides:



Advertisements
Similar presentations
Rezanje črt in poligonov. World window & viewport window viewport screen window world window.
Advertisements

Computer Graphics CLIPPING.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Java ThreadsGraphics Programming Graphics Programming: Windows, Viewports & Clipping.
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.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
David Breen, William Regli and Maxim Peysakhov
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 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
1 CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai.
Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Now Playing: California Stars Billy Bragg & Wilco from Mermaid Avenue
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
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.
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
Two-Dimensional Viewing
Clipping: Clipping is a process of dividing an object into visible and invisible positions and displaying the visible portion and discarding the invisible.
Two Dimensional Viewing
Computer Graphics 2 – Dimensional Viewing.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Windows, Viewports, and Clipping
Unit – IV 2D Viewing. 2 of 30 Contents Windowing Concepts The viewing pipeline viewing coordinate reference frame, window to view-port coordinate transformation,
EEL Introduction to Computer Graphics
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 3 1.
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
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Two-Dimensional Viewing Hearn & Baker Chapter 6
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Computer Graphics Clipping.
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Computer Graphics Viewing
2D Viewing & Clipping 한신대 류승택
2D Viewing Pipeline.
Concepts, algorithms for clipping
Graphics Pipeline Clipping
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND CLIPPING
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Two Dimensional Viewing and Clipping.
Clipping Polygons Lecture 31 Fri, Nov 9, 2007.
COMPUTER GRAPHICS Clipping
Presentation transcript:

2D Viewing

World Coordinates Viewport Coordinates Clipping Window World Coordinates The clipping window is mapped into a viewport. Viewing world has its own coordinates, which may be a non-uniform scaling of world coordinates. Viewport Viewport Coordinates

2D viewing transformation pipeline Construct World-Coordinate Scene From Modeling-Coordinate Transformations World Coordinates Modeling Coordinates Convert World- Coordinates to Viewing- Coordinates Viewing Coordinates Transform Viewing-Coordinates to Normalized- Coordinates Normalized Coordinates Map Normalized- Coordinates to Device-Coordinates Device Coordinates

Normalization and Viewport Transformations First approach: Normalization and window-to-viewport transformations are combined into one operation. Viewport range can be in [0,1] x [0,1]. Clipping takes place in [0,1] x [0,1]. Viewport is then mapped to display device. Second approach: Normalization and clipping take place before viewport transformation. Viewport coordinates are specified in screen coordinates.

Clipping Window Normalized Viewport 1 Maintain relative size and position between clipping window and viewport.

This can also be obtained by composing transformations: Scaling factors: Translation factors: This can also be obtained by composing transformations:

World clipping window can first be mapped to normalized square between -1 and +1, where clipping algorithm takes place, and then transform the scene into viewport given in display coordinates.

Clipping Algorithms Before Clipping After Clipping

Cohen-Sutherland Line Clipping Algorithm Intersection calculations are expensive. Find first lines completely inside or certainly outside clipping window. Apply intersection only to undecided lines. Perform cheaper tests before proceeding to expensive intersection calculations.

Cohen-Sutherland Line Clipping Algorithm Assign code to every endpoint of line segment. Borderlines of clipping window divide the plane into two halves. A point can be characterized by a 4-bit code according to its location in half planes. Location bit is 0 if the point is in the positive half plane, 1 otherwise. Code assignment involves comparisons or subtractions. Completely inside / certainly outside tests involve only logic operations of bits.

Endpoint codes are 0000 for both iff line is completely inside. Top bit Bottom bit Right bit Left bit 1 1 1 1 Endpoint codes are 0000 for both iff line is completely inside. If endpoint codes has 1 in same bit, line is certainly outside.

Lines that cannot be decided are intersected with window border lines. Each test clips the line and the remaining is tested again for full inclusion or certain exclusion, until remaining is either empty or fully contained. Endpoints of lines are examined against left, right, bottom and top borders (can be any order).

1

Liang-Barsky Line Clipping Algorithm Treat undecided lines in Cohen-Sutherland more efficiently. Define clipping window by intersections of four half-planes.

Nicholl-Lee-Nicholl Line Clipping Algorithm Creates more regions around clipping window to avoid multiple line intersection calculations. Performs fewer comparisons and divisions than Cohen-Sutherland and Liang-Barsky, but cannot be extended to 3D, while they can. For complete inclusion in clipping window or certain exclusion we’ll use Cohen-Sutherland.

T L B R

LT L LB LR

LT L LB LR

TB T TR L LB TR T LR L LB

TB T TR L LB TR T LR L LB

Sutherland-Hodgman Polygon Clipping 2 1 3 1’ 3’ 1’’ 3’’ 2’’ 2’ 1’ 3’ 1’’ 3’’ 2’’ 2’ Clipping Clipping Window Efficient algorithm for clipping convex polygons. Edges are clipped against every border line of clipping window. Edges are processed successively. Allows pipelining of edge clipping of polygons, as well as pipelining of different polygons.

The four possible outputs generated by the left clipper, depending on the relative position of pair of edge endpoints. out in output: in output: out output: none in out output:

[2’,3’]:(in-out)>{2”} [3’,1]:(in-in)>{1} [3’,1]:(out-out)>{} 1’ 2 2’ 2” 3 3’ Input Left Clipper Right Clipper Bottom Clipper Top Clipper [1,2]: (in-in)>{2} [2,3]: (in-out)>{2’} [2,2’]:(in-in)>{2’} [3,1]: (out-in)>{3’,1} [2’,3’]:(in-in)>{3’} [2’,3’]:(in-out)>{2”} [3’,1]:(in-in)>{1} [3’,1]:(out-out)>{} [1,2]:(in-in)>{2} [1,2]:(out-in)>{1’,2} [2”,1’]:(in-in)>1’} [1’,2]:(in-in)>{2} [2’,2”]:(in-in)>{2”}

The four clippers can work in parallel. Once a pair of endpoints it output by the first clipper, the second clipper can start working. The more edges in a polygon, the more effective parallelism is. Processing of a new polygon can start once first clipper finished processing. No need to wait for polygon completion.

Convex Polygon Intersection Q P∩Q Theorem: The intersection of an L-vertex convex polygon and an M-vertex convex polygon is a convex polygon of L+M vertices at most. Proof: P∩Q is an intersection of L+M interior half planes determined by the two polygons. Intersection of convex polygons can answer the question of whether two sets of points can be separated by a line.

Theorem: The intersection of an L-vertex convex polygon and an M-vertex convex polygon can be found in θ(L+M) time. Proof: Polygons are given in cyclic order of vertices. We start from the leftmost vertex of both polygons and progress along the border of both in a left-to-right fashion, defining O(L+M) slabs. Inside a slab each polygon forms a trapezoid. The intersection of two trapezoids can be calculated in constant time.

Another solution: The non empty intersection of two convex polygons forms a sequence of “sickles” enclosing the intersection. The border of a sickle comprises internal and external sequence of vertices originating from P and Q, which are alternating in every sickle. R=P∩Q P Q sickle Let P: (p1,p2,…,pL) and Q: (q1,q2,…,qM) be counterclockwise cyclically ordered. The algorithm advances such that ∂P and ∂Q are “chasing” one another, adjusting their speeds so that they meet at every intersection.

(a) (b)

(c) (d)

farthest vertex

case (b) case (d) case (c) farthest vertex case (a)