Today s class. Geometric objects and transformations. Informationsteknologi. Wednesday, November 7, 2007 Computer Graphics - Class 5 1

Similar documents
Two Dimensional Viewing

1. We ll look at: Types of geometrical transformation. Vector and matrix representations

CS F-07 Objects in 2D 1

What and Why Transformations?

CS559: Computer Graphics

[ ] [ ] Orthogonal Transformation of Cartesian Coordinates in 2D & 3D. φ = cos 1 1/ φ = tan 1 [ 2 /1]

Reteaching Golden Ratio

Image Warping : Computational Photography Alexei Efros, CMU, Fall Some slides from Steve Seitz

Plot and connect the points in a coordinate plane to make a polygon. Name the polygon.

Modeling Transformations

Editing and Transformation

Chapter 9 Transformations

Computer Graphics. Geometric Transformations

Computer Graphics. Geometric Transformations

CSE328 Fundamentals of Computer Graphics: Theory, Algorithms, and Applications

Image Warping. Some slides from Steve Seitz

Translations, Reflections, and Rotations

Pre-Algebra Notes Unit 13: Angle Relationships and Transformations

Modeling Transformations

12.1. Angle Relationships. Identifying Complementary, Supplementary Angles. Goal: Classify special pairs of angles. Vocabulary. Complementary. angles.

Glossary alternate interior angles absolute value function Example alternate exterior angles Example angle of rotation Example

Math 26: Fall (part 1) The Unit Circle: Cosine and Sine (Evaluating Cosine and Sine, and The Pythagorean Identity)

Name Class Date. subtract 3 from each side. w 5z z 5 2 w p - 9 = = 15 + k = 10m. 10. n =

5 and Parallel and Perpendicular Lines

Image Metamorphosis By Affine Transformations

4. Two Dimensional Transformations

Trigonometry Review Day 1

CS Computer Graphics: Transformations & The Synthetic Camera

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

CS770/870 Spring 2017 Transformations

Chap 7, 2009 Spring Yeong Gil Shin

Computer Graphics. Lecture 3 Graphics Output Primitives. Somsak Walairacht, Computer Engineering, KMITL

Image Warping. Many slides from Alyosha Efros + Steve Seitz. Photo by Sean Carroll

STRAND I: Geometry and Trigonometry. UNIT 37 Further Transformations: Student Text Contents. Section Reflections. 37.

H Geo Final Review Packet Multiple Choice Identify the choice that best completes the statement or answers the question.

3D Geometry and Camera Calibration

Answers to practice questions for Midterm 1

Think About. Unit 5 Lesson 3. Investigation. This Situation. Name: a Where do you think the origin of a coordinate system was placed in creating this

Computer Graphics. 2D Transforma5ons. Review Vertex Transforma5ons 2/3/15. adjust the zoom. posi+on the camera. posi+on the model

GLOBAL EDITION. Interactive Computer Graphics. A Top-Down Approach with WebGL SEVENTH EDITION. Edward Angel Dave Shreiner

CS 335 Graphics and Multimedia. Geometric Warping

Interactive Computer Graphics. Warping and morphing. Warping and Morphing. Warping and Morphing. Lecture 14+15: Warping and Morphing. What is.

9 3 Rotations 9 4 Symmetry

Properties Transformations

Modeling Transformations Revisited

THE INVERSE GRAPH. Finding the equation of the inverse. What is a function? LESSON

2D Object Definition (1/3)

Math 462: Review questions

Summer Dear Geometry Students and Parents:

Matrix Representations

Image warping. image filtering: change range of image. image warping: change domain of image g(x) = f(h(x)) h(y)=0.5y+0.5. h([x,y])=[x,y/2] f h

Image Warping. Some slides from Steve Seitz

CSE528 Computer Graphics: Theory, Algorithms, and Applications

angle The figure formed by two lines with a common endpoint called a vertex. angle bisector The line that divides an angle into two equal parts.

Parallel Lines Investigation

Transformations of Functions. 1. Shifting, reflecting, and stretching graphs Symmetry of functions and equations

Module 2, Section 2 Graphs of Trigonometric Functions

8.6 Three-Dimensional Cartesian Coordinate System

Double Integrals in Polar Coordinates

3D graphics rendering pipeline (1) 3D graphics rendering pipeline (3) 3D graphics rendering pipeline (2) 8/29/11

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

The Marching Cougars Lesson 9-1 Transformations

We can use square dot paper to draw each view (top, front, and sides) of the three dimensional objects:

GRAPHICS OUTPUT PRIMITIVES

Graphics Output Primitives

CS 548: COMPUTER GRAPHICS REVIEW: OVERVIEW OF POLYGONS SPRING 2015 DR. MICHAEL J. REALE

3D Coordinates & Transformations

13.2. General Angles and Radian Measure. What you should learn

Connecting Algebra and Geometry with Polygons

20 Calculus and Structures

Determining the 2d transformation that brings one image into alignment (registers it) with another. And

High Dimensional Rendering in OpenGL

Computer Graphics. Modelling in 2D. 2D primitives. Lines and Polylines. OpenGL polygon primitives. Special polygons

Homogeneous Coordinates

3-Dimensional Viewing

Worksheet on Line Symmetry & Rotational Symmetry

Geometric Model of Camera

Grade 7/8 Math Circles Fall October 9/10/11 Angles and Light

Isometries and Congruence

Transformations. which the book introduces in this chapter. If you shift the graph of y 1 x to the left 2 units and up 3 units, the

STRAND J: TRANSFORMATIONS, VECTORS and MATRICES

Polar Functions Polar coordinates

LESSON 3.1 INTRODUCTION TO GRAPHING

Scene Graphs & Modeling Transformations COS 426

Midterm Review. Wen-Chieh (Steve) Lin Department of Computer Science

Name: [20 points] Consider the following OpenGL commands:

Unit 6 Introduction to Trigonometry The Unit Circle (Unit 6.3)

Grade 6 Math Circles February 29, D Geometry

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

Transformations II. Week 2, Wed Jan 17

More Coordinate Graphs. How do we find coordinates on the graph?

WRITING AND GRAPHING LINEAR EQUATIONS ON A FLAT SURFACE #1313

Name: Unit 8 Beaumont Middle School 8th Grade, Advanced Algebra I T Q R U

14-1. Translations. Vocabulary. Lesson

Lesson 5: Definition of Rotation and Basic Properties

CS 157: Assignment 6

Image warping/morphing

Unit 2: Trigonometry. This lesson is not covered in your workbook. It is a review of trigonometry topics from previous courses.

PATTERNS AND ALGEBRA. He opened mathematics to many discoveries and exciting applications.

Transcription:

Toda s class Geometric objects and transformations Wednesda, November 7, 27 Computer Graphics - Class 5

Vector operations Review of vector operations needed for working in computer graphics adding two vectors subtracting two vectors scaling a vector magnitude of a vector normalizing a vector Wednesda, November 7, 27 Computer Graphics - Class 5 2

Linear combination of vectors Conve combinations (coefficients of linear combination are all non-negative and add up to ) Important conve combination: p(t) = a(-t) + b(t) where a and b are vectors and t If a and b are points, then p(t) = a(-t) + b(t) is said to interpolate the points a and b ( t ) Wednesda, November 7, 27 Computer Graphics - Class 5 3

Conve sets and hulls A conve set of points is a collection of points in which the line connecting an pair in the set lies entirel in the set Eamples: circle rectangle A conve hull is the smallest conve set that contains a specified collection of points Wednesda, November 7, 27 Computer Graphics - Class 5 4

Dot products cos θ = u a u b Vectors are orthogonal if dot product is Vectors are less than 9 apart if dot product is positive Vectors are more than 9 apart if dot product is negative Perpendicular projection of a onto b is (a u b ) u b Reflected ra is a -2(a u n ) u n where u n is a unit normal vector to the surface Wednesda, November 7, 27 Computer Graphics - Class 5 5

Cross products u = (u, u, u z ), v = (v, v, v z ) u v is perpendicular to both u and v Orientation follows the right hand rule u v = u v sin u v = θ u v u v u v z z z Wednesda, November 7, 27 Computer Graphics - Class 5 6

Polgons A polgon is a defined b a set of vertices and edges An interior angle of a polgon is an angle formed b two adjacent edges that is inside the boundar A conve polgon has ever interior angle < 8 A concave polgon is a polgon that is not conve Wednesda, November 7, 27 Computer Graphics - Class 5 7

Identifing concave polgons Concave polgons will have at least one interior angle > 8 The sin of this angle will be negative Thus, the magnitude of the cross product of the two vectors (edges) forming this angle will be negative This will also manifest itself b some z components of the cross product being positive and others being negative Wednesda, November 7, 27 Computer Graphics - Class 5 8

Splitting concave polgons Concave polgons present problems for computer graphics Splitting them up will get us conve polgons Define edge vector E k as the vector V k+ -V k, where the V s are adjacent vertices Calculate the edge cross products in order counter-clockwise around the polgon If an z component of a cross product is negative the polgon is concave and can be split along the line from the first edge in the cross product Wednesda, November 7, 27 Computer Graphics - Class 5 9

Triangularization A conve polgon can easil be triangularized (sometimes also referred to as tessellated) Define three consecutive vertices of the polgon as a triangle Remove the middle verte from the polgon s verte list Repeat with the modified list until onl three vertices remain, forming the last triangle Wednesda, November 7, 27 Computer Graphics - Class 5

Is a point inside a polgon? Even-odd test: construct a line from point to a point known to be outside polgon count # of intersections of line with boundar if odd, point is inside if crossing occurs at a verte look at endpoints of the edges that meet if both endpoints are on same side of line segment then the verte counts as an even number of crossings, otherwise it counts as an odd number Wednesda, November 7, 27 Computer Graphics - Class 5

N-gons An n-gon is a regular polgon of n sides Wednesda, November 7, 27 Computer Graphics - Class 5 2

Rosettes Rosettes are n-gons where each verte has been joined to each other verte Wednesda, November 7, 27 Computer Graphics - Class 5 3

A cube Consider a cube Pair off and come up with: A set of vertices for the cube A sequence of OpenGL statements to draw the cube How man function calls are ou making? Wednesda, November 7, 27 Computer Graphics - Class 5 4

Verte arras Allow ou to specif geometr with much fewer function calls For eample, the cube can be drawn in just one function call Create an arra of verte data and use glvertepointer() to refer to it Need to enable this with glenableclientstate (GL_VERTEX_ARRAY); Wednesda, November 7, 27 Computer Graphics - Class 5 5

glvertepointer() Four parameters: Size: number of coordinates per verte; must be 2, 3, or 4 Tpe: the data tpe of each coordinate in the arra Stride: the bte offset between consecutive vertices (frequentl ) Pointer: a pointer to the first coordinate of the first verte in the arra Wednesda, November 7, 27 Computer Graphics - Class 5 6

Inde arra Need a second arra with indices into the verte arra to specif which vertices make up each face of our geometr gldrawelements() is then used to draw the geometr Wednesda, November 7, 27 Computer Graphics - Class 5 7

gldrawelements() Four parameters: Mode: specified what kind of geometric primitives to render Count: number of vertices in the inde arra to be rendered Tpe: the tpe of the values in the inde arra; must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT Indices: a pointer to the arra of indices into the verte arra Wednesda, November 7, 27 Computer Graphics - Class 5 8

Eample program rotatingcube.c demonstrates verte arras and introduces the idle callback function Wednesda, November 7, 27 Computer Graphics - Class 5 9

Transformation matrices A transformation matri is a matri that transforms a point to another point In 2-dimensions, this has the following algebraic form: a a 2 a a 2 22 p p = a a 2 p p + + a a 2 22 p p Wednesda, November 7, 27 Computer Graphics - Class 5 2

Wednesda, November 7, 27 Computer Graphics - Class 5 2 Uniform scaling Given a scale factor s >, a matri which produces a uniform scaling is Eample: s s = sp sp p p s s

Wednesda, November 7, 27 Computer Graphics - Class 5 22 Non-uniform scaling Given scale factors s > and s >, a matri which produces non-uniform scaling is Eample: s s = p s p s p p s s

Comparison of scalings Uniform scaling preserves shape Non-uniform scaling introduces distortion Wednesda, November 7, 27 Computer Graphics - Class 5 23

Two scalings in a row Two scalings in a row have a multiplicative effect P = S P P = S 2 P = S 2 S P Note the order of the scales appears to be reversed (S 2 before S ), but it s not Wednesda, November 7, 27 Computer Graphics - Class 5 24

Wednesda, November 7, 27 Computer Graphics - Class 5 25 Composite transformation matri The product of two or more transformation matrices is known as a composite transformation matri For our two scalings we have = s s s s s s s s 2 2 2 2

A side effect Note that an object which does not have the origin inside it will be moved as well b a scaling We will see how to correct this effect shortl Wednesda, November 7, 27 Computer Graphics - Class 5 26

Reflections Reflection through the -ais negates the coordinate: Reflection through the -ais negates the coordinate: Wednesda, November 7, 27 Computer Graphics - Class 5 27

Rotation Rotation transforms a point in a circular manner Positive angles impl a counter-clockwise rotation Wednesda, November 7, 27 Computer Graphics - Class 5 28

The geometr of rotation (, ) r r (,) θ φ (, ) = (r cos φ, r sin φ) (, ) = (r cos (φ+θ), r sin (φ+θ)) Wednesda, November 7, 27 Computer Graphics - Class 5 29

Rotation formula (, ) = (r cos φ, r sin φ) (, ) = (r cos (φ+θ), r sin (φ+θ)) Recall sum of angle trig formulas: sin (φ+θ) = sin φ cos θ + cos φ sin θ cos (φ+θ) = cos φ cos θ -sin φ sin θ = r (cos φ cos θ - sin φ sin θ) = cos θ - sin θ = r (sin φ cos θ + cos φ sin θ) = cos θ + sin θ = sin θ + cos θ Wednesda, November 7, 27 Computer Graphics - Class 5 3

Rotation matri Results from the previous slide give the matri for rotation: ' ' cos sin = θ θ cos sin θ θ sin cos θ θ sin cos θ θ Wednesda, November 7, 27 Computer Graphics - Class 5 3

Two rotations in a row Two rotations in a row have an additive effect on the angles P = R P P = R 2 P = R 2 R P θ θ θ cos 2 sinθ2 sin cosθ cosθ 2 cosθ sinθ2 sinθ sinθ2 cosθ + cosθ 2 sinθ cos( θ2 + θ) sin( θ2 + θ) 2 2 cos sinθ sin( θ2 + θ) cos( θ + ) 2 θ sinθ = cosθ (cosθ sinθ + sinθ sinθ + sinθ2 cosθ) cosθ cos 2 θ Wednesda, November 7, 27 Computer Graphics - Class 5 32 2 2 =

Reflection through = = 45 Rotate point -45 so that reflection line is -ais Reflect through -ais Rotate 45 back Wednesda, November 7, 27 Computer Graphics - Class 5 33

. Rotate -45 Recall matri to perform rotation: Fill in θ = -45 : cos( 45 ) sin( 45 ) cosθ sinθ sinθ cosθ sin( 45 ) cos( 45 ) =.77.77.77.77 Wednesda, November 7, 27 Computer Graphics - Class 5 34

2. Reflect through -ais Recall matri for -ais reflection: Wednesda, November 7, 27 Computer Graphics - Class 5 35

3. Rotate back Recall matri to perform rotation: Fill in θ = 45 : cos(45 ) sin(45 ) cosθ sinθ sin(45 ) cos(45 ) sinθ cosθ =.77.77.77.77 Wednesda, November 7, 27 Computer Graphics - Class 5 36

Compute the total transformation Take each transformation matri in the order the transformations need to be applied and multipl them together:.77.77.77.77 =.77.77.77. 77 Wednesda, November 7, 27 Computer Graphics - Class 5 37

Wednesda, November 7, 27 Computer Graphics - Class 5 38 Result The result of reflecting a point through = is the switching of the and coordinates of the point = = ' '

Another transformation Find the transformation that reflects a point through the line = 2. =2 Wednesda, November 7, 27 Computer Graphics - Class 5 39

The steps Translate b -2 in the direction Reflect through the -ais Translate back Wednesda, November 7, 27 Computer Graphics - Class 5 4

Wednesda, November 7, 27 Computer Graphics - Class 5 4 Translation Translation is a transformation that results in a linear movement of a point + + = + = T T T T ' '

A problem with translation Ever other transformation we have looked at could be epressed using a 2 2 matri and multipling the point b the matri Translation cannot be epressed this wa as we need to add fied amounts to the and coordinates Wednesda, November 7, 27 Computer Graphics - Class 5 42

A solution So that translation behaves like our other transformations we want to epress it using a matri and multipling the point b the matri Will need to add an etra coordinate to our point This coordinate will have the value Wednesda, November 7, 27 Computer Graphics - Class 5 43

Wednesda, November 7, 27 Computer Graphics - Class 5 44 Translation matri The matri for doing a translation is Eample: T T + + = T T T T

Homogeneous coordinates This new representation for our points (with the in the etra coordinate) is known as homogeneous coordinates There are times when the homogeneous coordinate is not ; we ll see this in perspective projections Wednesda, November 7, 27 Computer Graphics - Class 5 45

New versions of transformation matrices Homogeneous coordinates requires a change in the transformation matrices to accommodate the etra coordinate Matrices will now be 3 3 Eample: uniform scaling s Wednesda, November 7, 27 Computer Graphics - Class 5 46 s

Wednesda, November 7, 27 Computer Graphics - Class 5 47 The transformations for our problem Translate b -2 in Reflect through -ais Translate b +2 in = 2 A = B = 2 C

The composite transformation The composite transformation for reflecting a point through the line =2 is found b multipling CBA: 4 Wednesda, November 7, 27 Computer Graphics - Class 5 48

Rotations about an arbitrar point The rotations we have considered so far all occur around the origin Suppose ou had the following figure, which ou would like to rotate about its center: Wednesda, November 7, 27 Computer Graphics - Class 5 49

Rotation analsis If we applied the rotation transformation as we currentl have it, the square would rotate about the origin This is not what we want We want the square to rotate in place Thus, we need to make the center of the square the point of rotation Wednesda, November 7, 27 Computer Graphics - Class 5 5

Fied points We call the point about which we want to rotate a fied point as it will not change its position during the transformation The same concept can be applied to scaling as well Wednesda, November 7, 27 Computer Graphics - Class 5 5

Wednesda, November 7, 27 Computer Graphics - Class 5 52 Steps for arbitrar rotation Translate the fied point to the origin Perform the rotation around the origin Translate the fied point back to its position = c c A = c c C = cos sin sin cos θ θ θ θ B

Reflection through an arbitrar line Consider the following picture: What steps are necessar to perform the indicated reflection? Wednesda, November 7, 27 Computer Graphics - Class 5 53

Arbitrar reflection transformation Sequence for arbitrar reflection: Translate line b its -intercept so that it goes through origin (T) Rotate around origin so line lies on -ais (R) Reflect through -ais (X) Rotate back (R - ) Translate back (T - ) Composite: T - R - XRT Wednesda, November 7, 27 Computer Graphics - Class 5 54