Unit-4 Geometric Objects and Transformations- I

Slides:



Advertisements
Similar presentations
Computer Graphics - Geometry & Representation -
Advertisements

Today Composing transformations 3D Transformations
Vectors, Points, Lines and Planes Jim Van Verth Lars M. Bishop
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
Vector Calculus Mengxia Zhu Fall Objective Review vector arithmetic Distinguish points and vectors Relate geometric concepts to their algebraic.
Demetriou/Loizidou – ACSC330 – Chapter 4 Geometric Objects and Transformations Dr. Giorgos A. Demetriou Dr. Stephania Loizidou Himona Computer Science.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Building Models modified by Ray Wisman Ed Angel Professor of Computer Science,
1 Building Models. 2 Objectives Introduce simple data structures for building polygonal models ­Vertex lists ­Edge lists OpenGL vertex arrays.
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Math Foundations of CG Math 1 Hofstra University.
2/7/2001Hofstra University – CSC290B1 Review: Math (Ch 4)
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
Modeling and representation 1 – comparative review and polygon mesh models 2.1 Introduction 2.2 Polygonal representation of three-dimensional objects 2.3.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Graphics CSE 581 – Interactive Computer Graphics Mathematics for Computer Graphics CSE 581 – Roger Crawfis (slides developed from Korea University slides)
COMP 175: Computer Graphics March 24, 2015
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Modeling. Geometric Models  2D and 3D objects  Triangles, quadrilaterals, polygons  Spheres, cones, boxes  Surface characteristics  Color  Texture.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Fundamentals of Computer Graphics Part 4
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
Intro to 3D Models Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
Mathematics for Graphics. 1 Objectives Introduce the elements of geometry  Scalars  Vectors  Points Develop mathematical operations among them in a.
©College of Computer and Information Science, Northeastern University CS 4300 Computer Graphics Prof. Harriet Fell Fall 2012 Lecture 12 – October 1, 2012.
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.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
Geometric Objects and Transformations
CAP 4730 Computer Graphic Methods Prof. Roy Levow Chapter 4.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
1 Graphics CSCI 343, Fall 2015 Lecture 9 Geometric Objects.
Computer Graphics I, Fall 2010 Building Models.
Computer Graphics I, Fall 2010 Geometry.
Graphics Graphics Korea University kucg.korea.ac.kr Geometric Primitives 고려대학교 컴퓨터 그래픽스 연구실.
Graphics Graphics Korea University kucg.korea.ac.kr Mathematics for Computer Graphics 고려대학교 컴퓨터 그래픽스 연구실.
4. Geometric Objects and Transformations
Objectives Introduce standard transformations Introduce standard transformations Derive homogeneous coordinate transformation matrices Derive homogeneous.
Vectors and the Geometry
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
- Introduction - Graphics Pipeline
Math Fundamentals Maths revisit.
Review: Transformations
Clipping Polygon Clipping Polygon : Area primitive
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
3D Graphics Rendering PPT By Ricardo Veguilla.
CSC461: Lecture 12 Geometry Objectives
Models and Architectures
Models and Architectures
Lecture 03: Linear Algebra
Models and Architectures
Introduction to Computer Graphics with WebGL
Building Models Ed Angel
Unit-5 Geometric Objects and Transformations-II
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University Transformations.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
3D Transformation CS380: Computer Graphics Sung-Eui Yoon (윤성의)
Lecture 13 Clipping & Scan Conversion
Chapter VII Rasterizer
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
Angel: Interactive Computer Graphics5E © Addison-Wesley 2009
CSE 411 Computer Graphics Lecture #2 Mathematical Foundations
Geometric Objects and Transformations (I)
Presentation transcript:

Unit-4 Geometric Objects and Transformations- I Course code: 10CS65 | Computer Graphics and Visualization Unit-4 Geometric Objects and Transformations- I Engineered for Tomorrow Prepared by : Asst. Prof. Sandhya Kumari Department: Computer Science and Engineering Date : dd.mm.yyyy

Geometric Transformations Concentration on 3D graphics Affine & Euclidean vector spaces Homogeneous coordinates Formalities of vector spaces & matrix algebra – see App.B&C Goals: method for dealing with geometric objects – independent of a coordinate system coordinate free approach & homogeneous coordinates

Scalars, Points & Vectors Most geometric objects can be defined by a limited set of primitives, like scalars, points, vectors Different perspectives: mathematical programming geometric BUT ALL are important for understanding vector = directed (oriented) line segment vectors have no fixed position!

Geometric View vectors have no fixed position had-to-tail rule – useful to express functionality C = A + B points & vectors – distinct geometric types! a given vector can be defined as from a fixed reference point (origin) to the given point p (dangerous vector repr.)

Vector & Affine Spaces Vector (linear) space vector & scalars – addition &multiplication operations used to form a scalar field (scalars – real, complex numbers, rational functions – typical Ax=0, n-tuples etc.) Affine space – extension of vector space – the point is an object vector-point addition, point-point subtraction, geometric operations with points etc. Euclidean space – enables to measure distance, size

Representation Mathematicians – scalars, points, vectors etc. – they are distinguished by symbols and fonts (bold, capital, italic etc.) Computer scientists – Abstract Data Types – ADT – set of operations on data; operations independent from the actual physical realization/implementation Data abstraction – fundamental to Computer Science but causes difficulties in a code understanding What is the meaning of a sequence in C++ : q = p + a * v;

Representation What is the meaning of a sequence in C++ : q = p + a * v; can be determined if the definition is known: vector u, v; point p, q; scalar a, b; and their actual meaning must be vector type as a vector ! OpenGL is not object oriented so far

Geometric ADT & Lines Symbols: , ,  - scalars P, Q, R – points u, v, w – vectors Typical geometrical operations: |  v| = |  | | v | v = P – Q => P = v + Q ( P – Q )+ ( Q – R ) = P – R P() = P0 +  d (a line in an affine space – param.form)

Affine Sums new point P can be defined as P = Q +  v Point R v = R – Q and P = Q + (R –Q)= R + (1- )Q P = 1 R+  2 Q where 1 +  2 = 1

Convexity A convex object is one for which any point lying on the line segment connecting any two points in the object is also in the object P = 1 R+  2 Q & 1+ 2 = 1 More general form P = 1P1+2P2 +... +nPn where 1+2 +... +n= 1 & i  0 , i = 1, 2, ....,n

Planes Let P, Q, R are points defining a plane in an affine space S() =  P + (1- )Q , 0   1 T() =  S + (1 - ) R , 0   1 using a substitution T(,) =  [ P + (1- )Q ] + ( 1 - ) R , 0   1 & 0   1 T(,) = P +  (1 -  )( Q – P ) + (1 - ) (R – P) Plane given by a point P0 and vectors u, v T(,) = P0 +  u +  v & 0  ,   1

Planes A triangle is defined as (a plane has no limits for ,  ) T(,) = P0 +  u +  v & 0 ,   1 If a point P lies in the plane then P - P0 =  u +  v Let w = u x v (cross product) The vector w is orthogonal to the plane and the equation wT (P – P0) = 0 (criterion for a test: point in the plane) vector w is called a normal vector and symbol n is often used

Three Dimensional Primitives Full range of graphics primitives cannot be supported by graphics systems – some are approximated most graphics systems optimized for procession points and polygons, polygons in E3 are not planar – tessellation is required or made by the system itself Constructive Solid Geometry (CSG) – objects build using set operations like union, intersection, difference etc.

Coordinate Systems and Frames A vector w is defined as w = 1v1 + 2v2 + 3v3 1, 2, 3 are components of w with respect to the basis vectors v1 ,v2 ,v3 vectors v forms coordinate system in vector space points representation needs to “fix” the origin – reference point and basis vectors are required - frame

Coordinate Systems and Frames Within a given frame every vector can be written uniquely as w = 1v1 + 2v2 + 3v3 just as in a vector space. v1 = [ 1, 0 , 0]T v2 = [ 0, 1 , 0]T v3 = [ 0, 0 , 1]T Every point can be written uniquely as w = P0 + 1v1 + 2v2 + 3v3

Changes of Coordinate Systems Suppose that {v1 , v2 , v3 } & {u1 , u2 , u3 } are two basis vectors. Therefore 9 scalar components exist { ij} such as u = M v a vector w with respect to v = [v1 , v2 , v3 ]T a = [1 , 2 , 3 ]T w = aT v a vector w with respect to v = [u1 , u2 , u3 ]T b = [ß1 , ß2 , ß3 ]T w = bT u w = bT u = bT M v = aT v bT M = aT  a = MT b

Changes of Coordinate Systems The origin unchanged - rotation, scaling representation u = M v Simple translation or a change of a frame cannot be represented in this way Study change of representation – chapter 4.3.2 on your own

Homogeneous coordinates A point P located at (x,y,z) is represented using a 3D frame by P0, v1, v2, v3 as p = [ x , y , z ]T therefore P = P0 + x v1+ y v2 + z v3 and point P can be determined as P = 1v1 + 2v2 + 3v3 + P0 P = [1 , 2 , 3 , 1] [v1 , v2 , v3 , P0 ]T Every point can be written uniquely as w = P0 + 1v1 + 2v2 + 3v3

Homogeneous Coordinates Suppose that {v1 , v2 , v3 , P0 }&{u1 , u2 , u3 , Q0 } are two basis vectors. Therefore 16 scalar components exist { ij} such as u = M v a vector w with respect to v = [v1 , v2 , v3 , P0 ]T  = [1 , 2 , 3 , 1]T w = aT v a vector w with respect to v = [u1 , u2 , u3 , Q0]T  = [ß1 , ß2 , ß3 , 1]T w = bT u w = bT u = bT M v = aT v bT M = aT  a = MT b Study Change in Frames and Frames&ADT Chapters 4.3.4.-5. on your own

Frames in OpenGL Two frames – camera & world frames Consider the camera frame fixed model-view matrix converts the homogeneous coordinate representations of points and vectors to their representations in the camera frame the model-view matrix is part of the state of the system – there is always a camera frame and a present-world frame (how to define new frames – next chapters) three basis vectors correspond to up, y, z -directions,

Frames in OpenGL Default settings: Camera & World frames the same Objects must moved away from camera or Camera must be moved away from objects If camera frame fixed & model-view positioning world frame to camera frame then model-view matrix A is defined as ( d- distance):

Frames in OpenGL Moves points (x,y,z) in the world frame to (x,y,z,-d) in the camera frame This concept is better than the repositioning objects position by changing their vertices Setting the Model-View matrix by sending an array of 16 elements to glLoadMatrix User working in the world coordinates positions the objects as before

Modeling a Colored Cube Problem: Draw a rotating cube. Tasks to be done: modeling converting to the camera frame clipping projection hidden surfaces removal rasterization display of the object

Modeling of a Cube Cube as 6 polygons – facets typedef GLfloat point3[3]; point3 vertices[8] = { {x,y,z},...{x,y,z}}; /* definition of the cube vertices */ ...... glBegin(GL_POLYGON); glVertex3fv(vertices[0]); glVertex3fv(vertices[3]); glVertex3fv(vertices[2]); glVertex3fv(vertices[1]); glEnd ( ); /* facet drawn */ outward facing - normal has right hand rule orientation

Data Structures for Object Represenation Advantages of the data structure: separation of topology and geometry geometry stored in the vertex list hg

Data Structures for Object Represenation typedef GLfloat point3[3]; point3 vertices [8] = {{x,y,z}, ... ,{x,y,z}}; /* vertices x,y,z coordinates def. */ GLfloat Colors[8][3] = {{r,g,b}, .... , {r,g,b}}; /* color defs. */ void quad(int a, int b, int c, int d) { glBegin(GL_QUADS); glColor3fv(colors[a]);glVertex3fv(vertices[a]); glColor3fv(colors[b]);glVertex3fv(vertices[b]); glColor3fv(colors[c]);glVertex3fv(vertices[c]); glColor3fv(colors[d]);glVertex3fv(vertices[d]); glEnd ( ); }

Data Structures for Object Representation color is specified - graphics system must decide how to fill bilinear interpolation C01() = (1- )C0+ C1 C23() = (1- )C2+ C3 for the given value  C01() = C4 , C23() = C5 C45() = (1- )C0+  C5 scan-line interpolation OpenGL provides this for others values that are assigned on the vertex-to-vertex basis void colorcube( );/*draws a cube*/ { quad(0,3,2,1); quad(2,3,7,6); quad(0,4,7,3); quad(1,2,6,5); quad(4,5,6,7); quad(0,1,5,4); }

Vertex Arrays glBegin, glEnd, glColor, glVertex – high overhead Vertex arrays – a glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); Arrays are the same as before GLfloat vertices [ ] = {.........}; GLfloat colors [ ] = {.........}; /* specification where the arrays are */ glVertexPointer(3,GL_FLOAT,0,vertices); glColorPointer(3,GL_FLOAT,0,colors); /* 3D vector, type, continuous (packed), pointer to the array */

Vertex Arrays The facets must be specified GLubyte cubeIndices [24] = {0,3,2,1,2,3,7,6,0,4,7,3,1,2,6,5,4,5,6,7,0,1,5,4}; /* facets are formed by 4 vertices */ Options how to draw: glDrawElements(type,n,format,pointer); -------------- SOLUTION ------------ for ( i=0; i<6; i++) /* n number of elements */ glDrawElements(GL_POLYGON,4, GL_UNSIGNED_BYTE, &cubeIndicis[4*i]); or with a single call glDrawElements(GL_QUADS,24, GL_UNSIGNED_BYTE, &cubeIndices);

Rotation, translation and Scaling Translation P’ = P + d Rotation x =  cos  y =  sin  x’ =  cos (+) y’ =  sin (+)

Rotation about a fixed point For rotation – implicit point origin 2D – simple 3D –complicated Transformation rigid-body non-rigid-body reflections

Conclusion Chapter 4 You have learnt in this chapter: how transformations are defined how can you use them how to construct quite complicated transformations Mention, please, that you are now capable to write quite complicated program with graphics output and input Next time we will learn how to represent different viewing principles, projections etc.