1 U08181 Computer Graphics Clipping Transformations –Transformations and matrices –Homogeneous matrices –Transformations in SVG.

Slides:



Advertisements
Similar presentations
9.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 9 – Clipping.
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 2D TRANSFORMATIONS.
Objectives Define Clipping Various clipping methods. Line clipping methods.
Line clipping: Line clipping algorithm is method of eliminate lines of outside area of the object,so outside of object viewing is Removed. Typically, any.
Computer Graphics Lecture 4 Geometry & Transformations.
1 Computer Graphics Chapter 8 3D Transformations.
Geometric Transformations
Computer Graphics, KKU. Lecture 81 Clipping on a Raster Display.
David Breen, William Regli and Maxim Peysakhov
Clipping Lines Lecture 7 Wed, Sep 10, The Graphics Pipeline From time to time we will discuss the graphics pipeline. The graphics pipeline is the.
CGPage: 1 東吳資訊科學 江清水 The process of clipping decides which part, if any, of a primitive lies inside the window. The algorithms used for line clipping can.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
TRANSFORMATIONS Reflections Rotations Enlargements Translations.
Chapter 4: Graphing & Inverse Functions Sections 4.2, 4.3, & 4.5 Transformations Sections 4.2, 4.3, & 4.5 Transformations.
2D TRANSFORMATIONS.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
1 Computer Graphics Chapter 4 2D Viewing Algorithms.
CS 4731: Computer Graphics Lecture 7: Introduction to Transforms, 2D transforms Emmanuel Agu.
Elementary 3D Transformations - a "Graphics Engine" Transformation procedures Transformations of coordinate systems Translation Scaling Rotation.
Graphics-1 Gentle Introduction to Computer Graphics (2) Based on: –David Brogan’s “Introduction to Computer Graphics” Course Slides, University of Virginia.
1 CSCE 441 Computer Graphics: 2D Transformations Jinxiang Chai.
©College of Computer and Information Science, Northeastern UniversityJune 26, CS U540 Computer Graphics Prof. Harriet Fell Spring 2009 Lecture 11.
REFLECTIONS, ROTATIONS AND TRANSLATIONS. Reflections.
Computer Graphics Clipping Cohen Sutherland Algorithm (Line) Cyrus-Back Algorithm (Line) Sutherland-Hodgeman Algorithm (Polygon) Cohen Sutherland Algorithm.
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.
Graphics Programming Graphics Programming: Transformations.
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
2D Transformations Unit - 3. Why Transformations? In graphics, once we have an object described, transformations are used to move that object, scale it.
1 Computer Graphics Week7 -2D Rotation. 3-Rotation A shape can be rotated about any of the three axes. A rotation about the z-axis will actually rotate.
UNIT - 5 3D transformation and viewing. 3D Point  We will consider points as column vectors. Thus, a typical point with coordinates (x, y, z) is represented.
2-Dimension Viewing and Clipping
Windowing and clipping
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
CS 325 Introduction to Computer Graphics 02 / 17 / 2010 Instructor: Michael Eckmann.
Transformational Geometry CS418 Computer Graphics John C. Hart.
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Functions and Models 1. Graphing Calculators and Computers 1.4.
1 Computer Graphics Clipping Fall FCC Line Clipping What happens when one or both endpoints of a line segment are not inside the specified drawing.
II-1 Transformations Transformations are needed to: –Position objects defined relative to the origin –Build scenes based on hierarchies –Project objects.
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
Objective – Students will be able to investigate graphs with different viewing windows or viewing screens. Therefore learning how important it is to choose.
Computer Graphic 2 D Transformation.
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Modeling Transformation
1 Using a Graphing Calculator A graphing calculator or computer displays a rectangular portion of the graph of an equation in a display window or viewing.
Lecture 10 Geometric Transformations In 3D(Three- Dimensional)
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphic 2 D Viewing.
Introduction to Computer Graphics with WebGL
Computer Graphics Shading in OpenGL
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Computer Graphics Transformations
Implementation I Ed Angel
Graphics Pipeline Clipping
Computer Graphics : Viewing In 2D
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Lines Jinxiang Chai
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Segment Clipping Simple algorithm. For each segment compute the intersection with the four sides of the rectangle, and then determine which sub-segment.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Window to Viewport Transformations
Transformations.
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Implementation I Ed Angel Professor Emeritus of Computer Science
CS U540 Computer Graphics Prof. Harriet Fell Spring 2007
Translation in Homogeneous Coordinates
Presentation transcript:

1 U08181 Computer Graphics Clipping Transformations –Transformations and matrices –Homogeneous matrices –Transformations in SVG

2 M08734 Introduction to Computer Graphics Clipping finding the parts of a shape that lie within (outside) a ‘clipping region’ useful for ‘window’ display

3 Possible intersections

4 Example: Cohen-Sutherland algorithm (xMin, yMin) (xMax, yMax) (x1, y1) Clip line to rectangle (x2, y2)

5 Clipping: value of set {right, top} {left, top} {right, bottom} {left, bottom} {bottom} {right} {left} {top} { }

6 Accepted and rejected lines If Encode(x1, y1)  Encode(x2, y2) = { } then line (x1, y1) to (x2, y2) lies entirely within clipping region If Encode(x1, x2)  Encode(x2, y2)  {} then line lies entirely outside region

7 Use of sets (Pascal syntax) S  T is written S + T (union) S  T is written S * T (intersection) x  S is written x IN S (membership)

8 Function Encode TYPE Edge = (left, right, bottom, top); EdgeSet = SET OF Edge; FUNCTION Encode (x, y: REAL): EdgeSet; VAR edges: EdgeSet; BEGIN edges := {}; IF x < xMin THEN edges := edges + {left} ELSIF x > xMax THEN edges := edges + {right} END; IF y < yMin THEN edges := edges + {bottom} ELSIF y > yMax THEN edges := edges + {top} END; RETURN edges END Encode;

9 Clipping PROCEDURE Clip (x1, y1, x2, y2, xMin, yMin, xMax, yMax: REAL); TYPE Edge = (left, right, bottom, top); EdgeSet = SET OF Edge; VAR p1Code, p2Code, code: EdgeSet; x, y: REAL; BEGIN p1Code := Encode(x1, y1); p2Code := Encode(x2, y2); WHILE (p1Code + p2Code # { }) & (p1Code * p2Code = { }) DO code := p1Code; IF code = { } THEN code := p2Code END; (* clip according to the set of encoded edges *) IF code = p1Code THEN x1 := x; y1 := y; p1Code := Encode(x1, y1) ELSE x2 := x; y2 := y; p2Code := Encode(x2, y2) END; (* (p1Code + p2Code = { }) OR (p1Code * p2Code # { }) *)

10 Do the clipping IF left IN code THEN x := xMin; y := y1 + (y2 - y1) * (xMin - x1) / (x2 - x1) ELSIF right IN code THEN x := xMax; y := y1 + (y2 - y1) * (xMax - x1) / (x2 - x1) END; IF bottom IN code THEN y:= yMin; x := x1 + (x2 - x1) * (yMin - y1) / (y2 - y1) ELSIF top IN code THEN y := yMax; x := x := x1 + (x2 - x1) * (yMax - y1) / (y2 - y1) END;

11 Draw the line (or not) (* (p1Code + p2Code = { }) OR (p1Code * p2Code # { }) *) IF p1Code + p2Code = { } THEN Line(ROUND(x1), ROUND(y1), ROUND(x2), ROUND(y2)) END

12 Transformations Translation Rotation Scaling

13 Translation Translation by tx and ty: x´ = x + tx y´ = y + ty

14 Rotation by angle  about (0, 0): x´ = x cos  – y sin  y´ = x sin  + y cos 

15 Scaling Scaling about (0, 0) by S x and S y : x´ = xS x y´ = yS y Note: negative S gives reflection

16 Matrices Represent point (x, y) by column vector:

17 Translation is vector addition

18 Rotation is matrix multiplication

19 Scaling is matrix multiplication

20 Homogeneous matrices It would be convenient if all transformations could be represented as matrix multiplication (cf translation) Solution: homogeneous matrices

21 Translation is matrix multiplication

22 Rotation is matrix multiplication

23 Scaling is matrix multiplication

24 Composition To rotate by  about a point (tx, ty) translate to origin rotate by  translate back Note order of matrix multiplications

25 Rotation by  about (tx, ty)

26 References