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

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Computer Graphics- SCC 342
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
COMPUTER GRAPHICS 2D TRANSFORMATIONS.
CMPE 466 COMPUTER GRAPHICS
Vector Calculus Mengxia Zhu Fall Objective Review vector arithmetic Distinguish points and vectors Relate geometric concepts to their algebraic.
Geometric Transformations
CS 450: Computer Graphics OVERVIEW OF POLYGONS
Sasha Vasserman.  Two triangles are similar if two pairs of corresponding angles are congruent.
Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Transformations II Week.
HCI 530 : Seminar (HCI) Damian Schofield. HCI 530: Seminar (HCI) Transforms –Two Dimensional –Three Dimensional The Graphics Pipeline.
Chapter 4.1 Mathematical Concepts
Computer Graphics - Class 14
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
CS 376 Introduction to Computer Graphics 02 / 09 / 2007 Instructor: Michael Eckmann.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Vectors.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
10/5/04© University of Wisconsin, CS559 Fall 2004 Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 3 due Oct 12 in class.
Unit 9: Vectors, Matrices and Transformations
Chapter 9: Geometry.
Mathematical Fundamentals
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Introduction to 3D Graphics Lecture 4: Scenes and Scene Graphs Anthony Steed University College London.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
Equation A statement that two mathematical expressions are equal.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Mathematical Foundations Sections A-1 to A-5 Some of the material in these slides may have been adapted from university of Virginia, MIT and Åbo Akademi.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Dx = 2 dy = 3 Y X D Translation A translation is applied to an object by repositioning it along a straight-line path.
Intro to 3D Models Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
Acute angle An angle with a measure less than 90 degrees.
Computer Graphics 2D Transformations. 2 of 74 Contents In today’s lecture we’ll cover the following: –Why transformations –Transformations Translation.
Geometric Objects and Transformation
Representation. Objectives Introduce concepts such as dimension and basis Introduce coordinate systems for representing vectors spaces and frames for.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 52 Computer Graphics Three-Dimensional Graphics I.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
Geometry Vocabulary 7-1 By: Hilary Clinger & Alex Shipherd.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
CAP 4730 Computer Graphic Methods Prof. Roy Levow Chapter 4.
Transformations To move a figure in the coordinate system to another location or image, by a rule.
Geometric Transformations
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Lesson 9-R Chapter 9 Review. Objectives Review chapter 9 material.
Affine Geometry.
Computer Graphics Matrices
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
II-1 Transformations Transformations are needed to: –Position objects defined relative to the origin –Build scenes based on hierarchies –Project objects.
 An image is the new figure, and the preimage is the original figure  Transformations-move or change a figure in some way to produce an image.
Unit 10 Transformations. Lesson 10.1 Dilations Lesson 10.1 Objectives Define transformation (G3.1.1) Differentiate between types of transformations (G3.1.2)
Acute angle: An angle with a measure less than 90º.
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Properties of Transformations. Translate Figures and Use Vectors Translation: moves every point of a figure the same distance in the same direction Image:
4. Geometric Objects and Transformations
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Lecture 5 Basic geometric objects
Computer Graphics CC416 Week 15 3D Graphics.
Clipping Polygon Clipping Polygon : Area primitive
Presentation transcript:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 52 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

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 53 Linear combination of vectors Convex combinations (coefficients of linear combination are all non-negative and add up to 1) Important convex combination: p(t) = a(1-t) + b(t) where a and b are vectors and 0  t  1 If a and b are points, then p(t) = a(1-t) + b(t) is said to interpolate the points a and b (0  t  1)

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 54 Convex sets and hulls A convex set of points is a collection of points in which the line connecting any pair in the set lies entirely in the set Examples:  circle  rectangle A convex hull is the smallest convex set that contains a specified collection of points

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 55 Dot products cos  = u a u b Vectors are orthogonal if dot product is 0 Vectors are less than 90° apart if dot product is positive Vectors are more than 90° apart if dot product is negative Perpendicular projection of a onto b is (a u b ) u b Reflected ray is a - 2(a u n ) u n where u n is a unit normal vector to the surface

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 56 Cross products u = (u x, u y, u z ), v = (v x, v y, v z ) u x v is perpendicular to both u and v Orientation follows the right hand rule

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 57 Polygons A polygon is a defined by a set of vertices and edges An interior angle of a polygon is an angle formed by two adjacent edges that is inside the boundary A convex polygon has every interior angle < 180° A concave polygon is a polygon that is not convex

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 58 Identifying concave polygons Concave polygons will have at least one interior angle > 180° 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 by some z components of the cross product being positive and others being negative

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 59 Splitting concave polygons Concave polygons present problems for computer graphics Splitting them up will get us convex polygons Define edge vector E k as the vector V k+1 -V k, where the V’s are adjacent vertices Calculate the edge cross products in order counter-clockwise around the polygon If any z component of a cross product is negative the polygon is concave and can be split along the line from the first edge in the cross product

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 510 Triangularization A convex polygon can easily be triangularized (sometimes also referred to as tessellated) Define three consecutive vertices of the polygon as a triangle Remove the middle vertex from the polygon’s vertex list Repeat with the modified list until only three vertices remain, forming the last triangle

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 511 Is a point inside a polygon? Even-odd test:  construct a line from point to a point known to be outside polygon  count # of intersections of line with boundary  if odd, point is inside  if crossing occurs at a vertex  look at endpoints of the edges that meet  if both endpoints are on same side of line segment then the vertex counts as an even number of crossings, otherwise it counts as an odd number

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 512 N-gons An n-gon is a regular polygon of n sides

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 513 Rosettes Rosettes are n-gons where each vertex has been joined to each other vertex

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 514 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 many function calls are you making?

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 515 Vertex arrays Allow you to specify geometry with much fewer function calls For example, the cube can be drawn in just one function call Create an array of vertex data and use glVertexPointer() to refer to it Need to enable this with glEnableClientState (GL_VERTEX_ARRAY);

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 516 glVertexPointer() Four parameters:  Size: number of coordinates per vertex; must be 2, 3, or 4  Type: the data type of each coordinate in the array  Stride: the byte offset between consecutive vertices (frequently 0)  Pointer: a pointer to the first coordinate of the first vertex in the array

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 517 Index array Need a second array with indices into the vertex array to specify which vertices make up each face of your geometry glDrawElements() is then used to draw the geometry

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 518 glDrawElements() Four parameters:  Mode: specified what kind of geometric primitives to render  Count: number of vertices in the index array to be rendered  Type: the type of the values in the index array; must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT  Indices: a pointer to the array of indices into the vertex array

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 519 Example program rotatingCube.c demonstrates vertex arrays and introduces the idle callback function

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 520 Transformation matrices A transformation matrix is a matrix that transforms a point to another point In 2-dimensions, this has the following algebraic form:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 521 Uniform scaling Given a scale factor s > 0, a matrix which produces a uniform scaling is Example:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 522 Non-uniform scaling Given scale factors s x > 0 and s y > 0, a matrix which produces non-uniform scaling is Example:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 523 Comparison of scalings Uniform scaling preserves shape Non-uniform scaling introduces distortion

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 524 Two scalings in a row Two scalings in a row have a multiplicative effect  P’ = S 1 P  P’’ = S 2 P’ = S 2 S 1 P Note the order of the scales appears to be reversed (S 2 before S 1 ), but it’s not

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 525 Composite transformation matrix The product of two or more transformation matrices is known as a composite transformation matrix For our two scalings we have

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 526 A side effect Note that an object which does not have the origin inside it will be moved as well by a scaling We will see how to correct this effect shortly

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 527 Reflections Reflection through the x-axis negates the y coordinate: Reflection through the y-axis negates the x coordinate:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 528 Rotation Rotation transforms a point in a circular manner Positive angles imply a counter-clockwise rotation

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 529 The geometry of rotation (x,y) (x’, y’)   r r (x, y) = (r cos , r sin  ) (x’, y’) = (r cos (  +  ), r sin (  +  ))

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 530 Rotation formula (x, y) = (r cos , r sin  ) (x’, y’) = (r cos (  +  ), r sin (  +  )) Recall sum of angle trig formulas:  sin (  +  ) = sin  cos  + cos  sin   cos (  +  ) = cos  cos  - sin  sin  x’ = r (cos  cos  - sin  sin  ) = x cos  - y sin  y’ = r (sin  cos  + cos  sin  ) = y cos  + x sin  = x sin  + y cos 

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 531 Rotation matrix Results from the previous slide give the matrix for rotation:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 532 Two rotations in a row Two rotations in a row have an additive effect on the angles  P’ = R 1 P  P’’ = R 2 P’ = R 2 R 1 P

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 533 Rotate point -45° so that reflection line is x-axis Reflect through x-axis Rotate 45° back Reflection through y=x y = x 45°

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 534 Recall matrix to perform rotation: Fill in  = -45°: 1. Rotate -45°

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class Reflect through x-axis Recall matrix for x-axis reflection:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 536 Recall matrix to perform rotation: Fill in  = 45°: 3. Rotate back

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 537 Compute the total transformation Take each transformation matrix in the order the transformations need to be applied and multiply them together:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 538 Result The result of reflecting a point through y=x is the switching of the x and y coordinates of the point

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 539 Another transformation Find the transformation that reflects a point through the line y = 2. y=2

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 540 The steps Translate by -2 in the y direction Reflect through the x-axis Translate back

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 541 Translation Translation is a transformation that results in a linear movement of a point

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 542 A problem with translation Every other transformation we have looked at could be expressed using a 2  2 matrix and multiplying the point by the matrix Translation cannot be expressed this way as we need to add fixed amounts to the x and y coordinates

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 543 A solution So that translation behaves like our other transformations we want to express it using a matrix and multiplying the point by the matrix Will need to add an extra coordinate to our point This coordinate will have the value 1

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 544 Translation matrix The matrix for doing a translation is Example:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 545 Homogeneous coordinates This new representation for our points (with the 1 in the extra coordinate) is known as homogeneous coordinates There are times when the homogeneous coordinate is not 1; we’ll see this in perspective projections

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 546 New versions of transformation matrices Homogeneous coordinates requires a change in the transformation matrices to accommodate the extra coordinate Matrices will now be 3  3 Example: uniform scaling

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 547 The transformations for our problem Translate by -2 in y Reflect through x-axis Translate by +2 in y

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 548 The composite transformation The composite transformation for reflecting a point through the line y=2 is found by multiplying CBA:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 549 Rotations about an arbitrary point The rotations we have considered so far all occur around the origin Suppose you had the following figure, which you would like to rotate about its center:

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 550 If we applied the rotation transformation as we currently 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 Rotation analysis

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 551 We call the point about which we want to rotate a fixed point as it will not change its position during the transformation The same concept can be applied to scaling as well Fixed points

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 552 Steps for arbitrary rotation Translate the fixed point to the origin Perform the rotation around the origin Translate the fixed point back to its position

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 553 Consider the following picture: What steps are necessary to perform the indicated reflection? Reflection through an arbitrary line

Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 554 Arbitrary reflection transformation Sequence for arbitrary reflection:  Translate line by its y-intercept so that it goes through origin (T)  Rotate around origin so line lies on x-axis (R)  Reflect through x-axis (X)  Rotate back (R -1 )  Translate back (T -1 ) Composite: T -1 R -1 XRT