Clipping Polygon Clipping Polygon : Area primitive

Slides:



Advertisements
Similar presentations
Computer Graphics- SCC 342
Advertisements

Computer Graphics Lecture 4 Geometry & Transformations.
Geometric Transformations
David Breen, William Regli and Maxim Peysakhov
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
2D/3D Geometric Transformations CS485/685 Computer Vision Dr. George Bebis.
1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Graphics Graphics Korea University cgvr.korea.ac.kr 2D Geometric Transformations 고려대학교 컴퓨터 그래픽스 연구실.
Lecture Notes: Computer Graphics.
2D Geometric Transformations
Graphics Graphics Korea University cgvr.korea.ac.kr 1 2D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
Geometric Objects and Transformation
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Introduction to Computer Graphics Geometric Transformations
Two-Dimensional Geometric Transformations ch5. 참조 Subjects : Basic Transformations Homogeneous Coordinates Composite Transformations Other Transformations.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Multimedia Programming 07: Image Warping Keyframe Animation Departments of Digital Contents Sang Il Park.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
CSC418 Computer Graphics n Polygons –Triangulation –Scan conversion –Convex/Concave – clipping) n 2D affine transformations and properties, Homogeneous.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Computer Graphic 2 D Transformation.
Image Warping 2D Geometric Transformations
Modeling Transformation
Instructor: Dr. Shereen Aly Taie Basic Two-Dimensional Geometric Transformation 5.2 Matrix Representations and Homogeneous Coordinates 5.3 Inverse.
Transformations University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
Forward Projection Pipeline and Transformations CENG 477 Introduction to Computer Graphics.
Computer Graphics Clipping.
Geometric Transformations
Transformations Objectives
3. Transformation
Computer Graphics Transformations.
2D Transformations with Matrices
Review: Transformations
GEOMETRIC TRANSFORMATIONS Yingcai Xiao
Introduction to Polygons
3D Geometric Transformations
Transformations contd.
Polygons.
Computer Graphics Transformations.
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Computer Graphics Viewing
Introduction to Computer Graphics CS 445 / 645
Review: Transformations
Fill Area Algorithms Jan
2D Transformations y y x x y x.
Computer Graphics Transformations
Graphics Pipeline Clipping
Image Warping : Computational Photography
Transformations.
COMP 175: Computer Graphics February 9, 2016
WINDOWING AND CLIPPING
OpenGL 2D Viewing Pipeline
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Image Warping : Computational Photography
WINDOWING AND CLIPPING
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
2D Geometric Transformations
Geometric Transformations
Transformations Ed Angel
Geometrical Transformations
Clipping Polygons Dr. Scott Schaefer.
NOTE.
3D transformations Dr Nicolas Holzschuch University of Cape Town
TWO DIMENSIONAL TRANSFORMATION
Presentation transcript:

Clipping Polygon Clipping Polygon : Area primitive Simple Polygon: Planar set of ordered points No line crossings No holes V3 V4 V1 V2 Simple Polygon Line Crossing Hole

Clipping Polygon Clipping Polygon : Area primitive Non-Convex Polygon

Clipping Polygon Clipping Sutherland-Hodgman Window must be convex Polygon to be clipped can be convex or non-convex Polygon Polygon Window

Clipping Polygon Clipping Sutherland-Hodgman Window must be convex Polygon to be clipped can be convex or non-convex

Clipping Polygon Clipping Sutherland-Hodgman

Clipping Polygon Clipping Sutherland-Hodgman Approach Polygon to be clipped is given as v1, v2, …, vn Polygon edge is a pair [vi, vi+1] Process all polygon edges in succession against a window edge polygon (v1, v2, …, vn) polygon (w1, w2, …, wm) Repeat on resulting polygon with next window edge

Clipping Polygon Clipping Sutherland-Hodgman Approach Four Cases s = vi is the polygon edge starting vertex p = vi+1 is the polygon edge ending vertex i is a polygon-edge/window-edge intersection point wj is the next polygon vertex to be output

Clipping Polygon Clipping Sutherland-Hodgman Approach Case 1: Polygon edge is entirely inside the window edge Inside Outside s p is next vertex of resulting polygon p wj and j+1 j p Output

Clipping Polygon Clipping Sutherland-Hodgman Approach Case 2: Polygon edge crosses window edge going out Inside Outside Intersection point i is next vertex of resulting polygon i wj and j+1 j p s i Output

Clipping Polygon Clipping Sutherland-Hodgman Approach Case 3: Polygon edge is entirely outside the window edge Inside Outside p No output s

Clipping Polygon Clipping Sutherland-Hodgman Approach Case 4: Polygon edge crosses window edge going in Inside Outside Output s p i Intersection point i and p are next two vertices of resulting polygon i wj and p wj+1 and j+2 j

Clipping Polygon Clipping Sutherland-Hodgman Example s5 s4 s3 s2 s1 Window s1

Clipping Polygon Clipping Sutherland-Hodgman Example s5 s4 i2 i1 s3 s2

Clipping Polygon Clipping Sutherland-Hodgman Example t4 t3 t2 t1 t5

Clipping Polygon Clipping Sutherland-Hodgman Example u3 u2 u1 u5 u4

Clipping Polygon Clipping Sutherland-Hodgman Example v2 i3 v1 i6 v5 i5

Clipping Polygon Clipping Sutherland-Hodgman Example w1 w6 w5 w4 w3 w2

Polygon Scan Conversion Polygon Filling Consider first triangle

Polygon Scan Conversion Polygon Filling Consider first triangle Color all pixels inside triangle Inside (containment) test

Polygon Scan Conversion Polygon Filling Triangle Use horizontal spans. Process horizontal spans in scan-line order. For the next spans use edge slopes XL XR

Polygon Scan Conversion Polygon Filling Polygon How do we decide what parts of the span should be filled ?

Polygon Scan Conversion Polygon Filling Polygon How do we decide what parts of the span should be filled ? Parity check if odd fill if even don’t fill

Polygon Scan Conversion Polygon Filling Polygon What happens here?

Polygon Scan Conversion Polygon Filling Polygon What happens here?

Polygon Scan Conversion Polygon Filling Polygon Recursive seed filling

Geometrical Transformation Translation P ( x , y ) ® P ' ( x ' , y ' ) P’ x ' = x + t ; y ' = y + t x y P T P ' = P + T P = [ x , y ]; T = [ t , t ] x y

Geometrical Transformation Scaling P ( x , y ) ® P ' ( x ' , y ' ) x ' = s x ; y ' = s y x y é s ù x [ x ' , y ' ] = [ x , y ] ê ú s ë û y P ' = P . S

Geometrical Transformation Scaling P ( x , y ) ® P ' ( x ' , y ' ) x ' = s x ; y ' = s y x y é s ù [ x ' ' x , y ] = [ x , y ] ê ú s ë û y P ' = P . S s = s : uniform scaling x y s ¹ s : differenti al scaling x y

Geometrical Transformation Rotation P ( x , y ) ® P ' ( x ' , y ' ) x = r cos( φ ); y = r sin( φ ) x ' = r cos( φ + θ ) P’ y ' = r sin( φ + θ ) q P ' = - f x x cos( θ ) y sin( θ ) y ' = x sin( θ ) + y cos( θ ) é cos( θ ) sin( θ ) ù [ x ' , y ' ] = [ x , y ] ê ú - ë sin( θ ) cos( θ ) û P ' = P . R θ

Geometrical Transformation General 2x2 Matrix X ® X ' X ' = X . T é a b ù [ x ' , y ' ] = [ x , y ] = [( ax + cy ), ( bx + dy )] ê ú ë c d û If a = d = 1 and b = c = 0 T = Identity Matrix X’ = X

Geometrical Transformation General 2x2 Matrix y If b = c = 0 X’ = [ax, dy] : Scaling If b = c = 0 and a = -1, d = 1 X’ = [-x, y] : Reflection P’ P x

Geometrical Transformation General 2x2 Matrix é 1 ù Shearing in X [ x ' , y ' ] = [ x , y ] = [ x + cy , y ] ê ú ë c 1 û

Geometrical Transformation General 2x2 Matrix é 1 b ù Shearing in Y [ x ' , y ' ] = [ x , y ] = [ x , bx + y ] ê ú ë 1 û

Geometrical Transformation Homogenous Coordinates Scale/Rotate/Reflect/Shear: X’ = XT Translate: X’ = X + T P = [ x , y ] P = [ x , y , w ] h Multiple values for the same point e.g., (2, 3, 6) and (4, 6, 12) are same points

Geometrical Transformation Homogenous Coordinates w (x, y,w) (x/w, y/w,1) w=1 x y

Geometrical Transformation Homogenous Coordinates Unifying representation for transformation Transformation matrix from 2x2 to 3x3 X ® X ' X ' = X . T é a b ù ê ú [ x ' , y ' , w ] = [ x , y , 1 ] c d ê ú ë ê l m 1 ú û = [( ax + cy + l ), ( bx + dy + m ), 1 ]

Geometrical Transformation Homogenous Coordinates Translation é 1 ù ê ú T = 1 ê ú ê l m 1 ú ë û X ' = XT [ x ' , y ' ] = [ x + l , y + m ]

Geometrical Transformation Homogenous Coordinates Scaling/Rotation/Shear é a b ù ê ú T = c d ê ú ë ê 1 ú û

Geometrical Transformation Homogenous Coordinates Successive translations: T1 = (l1, m1), T2 = (l2, m2) After T1 After T1 and T2 Successive translations are additive

Geometrical Transformation Homogenous Coordinates Successive scaling: S1 = (sx1, sy1), S2 = (sx2, sy2) After S1 After S1 and S2 Successive scaling is multiplicative

Geometrical Transformation Homogenous Coordinates Successive rotations: R(q), R(f) After R(q) After R(q) and R(f) Successive rotations are additive

Geometrical Transformation Composition of transformation Rotation about arbitrary point y Rotation about origin is known Translate such that P becomes O Rotate (about O) Translate back to P P O x

Geometrical Transformation Composition of transformation Rotation about arbitrary point y Rotation about origin is known Translate such that P becomes O P O x

Geometrical Transformation Composition of transformation Rotation about arbitrary point y Rotation about origin is known Rotate about O O x

Geometrical Transformation Composition of transformation Rotation about arbitrary point y Rotation about origin is known Translate back to P P O x

Geometrical Transformation Composition of transformation Composite transformation

Geometrical Transformation Composition of transformation Reflection about an arbitrary line B y C A O x

Geometrical Transformation Composition of transformation Reflection about an arbitrary line y B Translation C A O x

Geometrical Transformation Composition of transformation Reflection about an arbitrary line y B Rotation A C O x

Geometrical Transformation Composition of transformation Reflection about an arbitrary line y Reflection O x A C B

Geometrical Transformation Composition of transformation Reflection about an arbitrary line y Rotation C O A x B

Geometrical Transformation Composition of transformation Reflection about an arbitrary line y Translation C A O x B

Geometrical Transformation Composition of transformation Given T1 and T2 In general,

Geometrical Transformation Rigid Transformations Square remains square Preserves length and angles Sequence of rotations and translations é r r ù 11 12 ê ú T = r r ê 21 22 ú ê ë l m 1 ú û

Geometrical Transformation Affine Transformations Preserves parallelism Sequence of rotations, translations, scaling and shear Linear transformation is when no translation

Geometrical Transformation General Transformation 3x3 matrix