Geometric Objects and Transformations Chapter 4. Points, Scalars and Vectors  Points - position in space  Scalars - real numbers, complex numbers obey.

Slides:



Advertisements
Similar presentations
OpenGL Computer Graphics
Advertisements

Today Composing transformations 3D Transformations
OPENGL.
3D Game Programming Geometric Transformations
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Chapter 4.1 Mathematical Concepts
Viewing and Transformation
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
Drawing 3D Scenes in OpenGL We want to transform objects in order to orient and position them as desired in a 3D scene. OpenGL provides the necessary functions.
2.1 si SI31 Advanced Computer Graphics AGR Lecture 2 Basic Modelling.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
3-D Geometry.
3D orientation.
Computer Graphics CSC 630 Lecture 2- Linear Algebra.
Computer Graphics with OpenGL 3e
1 Lecture 5 Rendering 3D graphical primitives. 2 3D Rendering Example:
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
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.
CS 4731: Computer Graphics Lecture 9: Introduction to 3D Modeling Emmanuel Agu.
CS 470 Introduction to Computer Graphics Basic 3D in OpenGL.
Mathematical Fundamentals
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Rotations and Translations
COS 397 Computer Graphics Svetla Boytcheva AUBG, Spring 2013.
Chapter 4.1 Mathematical Concepts
COMP 175: Computer Graphics March 24, 2015
UniS CS297 Graphics with Java and OpenGL Viewing, the model view matrix.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
Transformation of Graphics
Transformations Dr. Amy Zhang.
Chapter 4 10 February Agenda Program 2 – Due 2/17 Chapter 4 – transformations GLUT solids.
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.
CSE 681 Review: Transformations. CSE 681 Transformations Modeling transformations build complex models by positioning (transforming) simple components.
Geometric Transformations
Stages of Vertex Transformation To specify viewing, modeling, and projection transformations, you construct a 4 × 4 matrix M, which is then multiplied.
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
1 Computer Graphics Week9 -3D Geometric Transformation.
Computer Graphics Bing-Yu Chen National Taiwan University.
16/5/ :47 UML Computer Graphics Conceptual Model Application Model Application Program Graphics System Output Devices Input Devices API Function.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
Viewing and Transformation. Pixel pipeline Vertex pipeline Course Map Transformation & Lighting Primitive assembly Viewport culling & clipping Texture.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
Chap 3 Viewing and Transformation
Computer Graphics Matrices
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Learning Objectives Affine transformations Affine transformations Translation Translation Rotation Rotation Scaling Scaling Reflection Reflection Shear.
1 By Dr. HANY ELSALAMONY.  We have seen how to create models in the 3D world. We discussed transforms in lecture 3, and we have used some transformations.
Homogeneous Coordinates and Matrix Representations Cartesian coordinate (x, y, z) Homogeneous coordinate (x h, y h, z h, h) Usually h = 1. But there are.
Computer Graphics I, Fall 2010 Transformations.
Geometric Transformations Ceng 477 Introduction to Computer Graphics Computer Engineering METU.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
David Luebke6/12/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Transformations. Transformations Introduce standard transformations ◦ Rotation ◦ Translation ◦ Scaling ◦ Shear Derive homogeneous coordinate transformation.
Modeling Transformation
Modeling Transformations Mario Costa Sousa University of Calgary CPSC 453, Fall 2001 Mario Costa Sousa University of Calgary CPSC 453, Fall 2001.
Computer Graphics Lecture 42 Viewing Using OpenGL II Taqdees A. Siddiqi
Chapter 8 Three-dimensional Object Representations PART I
LAB 5 Drawing Objects Lab 5 Drawing Objects.
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.
LAB 5 Drawing Objects Lab 5 Drawing Objects.
2D Geometric Transformations
LAB 5 Drawing Objects Lab 5 Drawing Objects.
Geometric Objects and Transformations (II)
Chapter 4 15 March 2006 EventPro Strategies is looking for a part-time programmer (any language) who knows SQL. For more info, contact Ryan Taylor,
Presentation transcript:

Geometric Objects and Transformations Chapter 4

Points, Scalars and Vectors  Points - position in space  Scalars - real numbers, complex numbers obey a set of rules that are abstractions of arithmetic store values such as distance  Vectors - directed line segment  Points - position in space  Scalars - real numbers, complex numbers obey a set of rules that are abstractions of arithmetic store values such as distance  Vectors - directed line segment

Vector Arithmetic  B = 2A  C = A + B  Head to tail rule  E = -A  Inverse  Zero vector = E + A  B = 2A  C = A + B  Head to tail rule  E = -A  Inverse  Zero vector = E + A

Point Arithmetic  Can’t add p1 + p2 = p3  Can’t multiply p1 * 2 = p2  What can you do to produce a 2nd point from a 1st?  p1 + V = p2  V = p2 - p1  Can’t add p1 + p2 = p3  Can’t multiply p1 * 2 = p2  What can you do to produce a 2nd point from a 1st?  p1 + V = p2  V = p2 - p1

Important Vector Concepts  Normal Vector  A vector at a right angle to a surface.  Graphics Usage of Normal Vector  Used to figure out similarity of direction which is necessary for lighting  More precisely, how much light should fall on a surface is calculated by the similarity of the surface normal and the vector between the light source and the surface.  Similarity of direction = vector dot product  Normal Vector  A vector at a right angle to a surface.  Graphics Usage of Normal Vector  Used to figure out similarity of direction which is necessary for lighting  More precisely, how much light should fall on a surface is calculated by the similarity of the surface normal and the vector between the light source and the surface.  Similarity of direction = vector dot product

Vector Dot Product  For vectors of length 1 (unit vectors), the dot product is the length of the projection of one vector onto the other.  If the dot product =  1: the vectors point in the same direction  0: the vectors are at right angles  -1: the vectors point in opposite directions  For vectors of length 1 (unit vectors), the dot product is the length of the projection of one vector onto the other.  If the dot product =  1: the vectors point in the same direction  0: the vectors are at right angles  -1: the vectors point in opposite directions

Vector Cross Product  The cross product of two vectors A and B is another vector at right angles to the plane created by A and B

Defining a Coordinate Space  Need to know 1.The origin (or displacement vector) 2.The basis vectors - The direction and distance for +1 movement along each axis  This definition is relative  To plot a point 1.Begin at origin 2.Travel along the x basis vector [direction] scaled by x coord, then along the y basis vector scaled by the y coord, then finally along the z basis vector scaled by the z coord.  Need to know 1.The origin (or displacement vector) 2.The basis vectors - The direction and distance for +1 movement along each axis  This definition is relative  To plot a point 1.Begin at origin 2.Travel along the x basis vector [direction] scaled by x coord, then along the y basis vector scaled by the y coord, then finally along the z basis vector scaled by the z coord.

Transformations  Prior to rendering: view, locate and orient  eye / camera position  3D geometry  Manage the matrices  including the matrix stack  Combine (composite) transformations  Prior to rendering: view, locate and orient  eye / camera position  3D geometry  Manage the matrices  including the matrix stack  Combine (composite) transformations

Camera Analogy

Stages of Vertex Transformation

Transformations  45-degree counterclockwise rotation about the origin around the z-axis  a translation down the x-axis  45-degree counterclockwise rotation about the origin around the z-axis  a translation down the x-axis

Order of Transformations  transformed vertex is NMLv glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixf(N); /* apply transformation N */ glMultMatrixf(M); /* apply transformation M */ glMultMatrixf(L); /* apply transformation L */ glBegin(GL_POINTS); glVertex3f(v); /* draw transformed vertex v */ glEnd();

Translation  void glTranslate{fd} (TYPE x, TYPE y, TYPE z);  Multiplies the current matrix by a matrix that moves (translates) an object by the given x, y, and z values  void glTranslate{fd} (TYPE x, TYPE y, TYPE z);  Multiplies the current matrix by a matrix that moves (translates) an object by the given x, y, and z values

Rotation  void glRotate{fd}(TYPE angle, TYPE x, TYPE y, TYPE z);  Multiplies the current matrix by a matrix that rotates an object in a counterclockwise direction about the ray from the origin through the point (x, y, z). The angle parameter specifies the angle of rotation in degrees.  void glRotate{fd}(TYPE angle, TYPE x, TYPE y, TYPE z);  Multiplies the current matrix by a matrix that rotates an object in a counterclockwise direction about the ray from the origin through the point (x, y, z). The angle parameter specifies the angle of rotation in degrees.

Scale  void glScale{fd} (TYPEx, TYPE y, TYPEz);  Multiplies the current matrix by a matrix that stretches, shrinks, or reflects an object along the axes.  void glScale{fd} (TYPEx, TYPE y, TYPEz);  Multiplies the current matrix by a matrix that stretches, shrinks, or reflects an object along the axes.

Vectors =

Matrices  Rectangular array of numbers  A vector in 3 space is a n x 1 matrix or columnvector.  Multiplication  Rectangular array of numbers  A vector in 3 space is a n x 1 matrix or columnvector.  Multiplication x /k 1 Cos α 0 sin α m -sin α 0 cos α n

Matrix Multiplication  A is an n x m matrix with entries a ij  B is an m x p matrix with entries b ij  AB is an n x p matrix with entries c ij m  c ij =  a is b sj s=1  A is an n x m matrix with entries a ij  B is an m x p matrix with entries b ij  AB is an n x p matrix with entries c ij m  c ij =  a is b sj s=1

2D Transformations  Translation: Pf = T + P x f = x o + dx y f = y o + dy  Rotation: Pf = R · P x f = x o * cos  - y o *sin  y f = x o * sin  + y o *cos   Scale: Pf = S · P x f = sx * x o y f = sy * y o  Translation: Pf = T + P x f = x o + dx y f = y o + dy  Rotation: Pf = R · P x f = x o * cos  - y o *sin  y f = x o * sin  + y o *cos   Scale: Pf = S · P x f = sx * x o y f = sy * y o

Homogeneous Coordinates  Want to treat all transforms in a consistent way so they can be combined easily  Developed in geometry (‘46 in cambridge) and applied to graphics  Add a third coordinate to a point (x, y, w)  (x1, y1, w1) is the same point as (x2, y2, w2) if one is a multiple of another  Homogenize a point by dividing by w  Want to treat all transforms in a consistent way so they can be combined easily  Developed in geometry (‘46 in cambridge) and applied to graphics  Add a third coordinate to a point (x, y, w)  (x1, y1, w1) is the same point as (x2, y2, w2) if one is a multiple of another  Homogenize a point by dividing by w

Homogeneous Coordinates 1 0 dxx 0 1 dy · y * x+ 0 * y + dx * 1 0 * x+ 1 * y + dy * 1 0 * x+ 0 * y + 1 * dxx 0 1 dy · y * x+ 0 * y + dx * 1 0 * x+ 1 * y + dy * 1 0 * x+ 0 * y + 1 * 1

Homogeneous Coordinates 1 0 dxx 0 1 dy · y dxx 0 1 dy · y

Homogeneous Coordinates sx 0 0 x 0 sy 0 · y sx 0 0 x 0 sy 0 · y

Homogeneous Coordinates Cos  -sin  0 x sin  cos  0 · y Cos  -sin  0 x sin  cos  0 · y

Homogeneous Coordinates x x · y = y  Identity Maxtrix x point p = point p x x · y = y  Identity Maxtrix x point p = point p

Combining 2D Transformations  Rotate a house about the origin  Rotate the house about one of its corners  translate so that a corner of the house is at the origin  rotate the house about the origin  translate so that the corner returns to its original position  Rotate a house about the origin  Rotate the house about one of its corners  translate so that a corner of the house is at the origin  rotate the house about the origin  translate so that the corner returns to its original position

OpenGL Buffers  Color  can be divided into front and back for double buffering  Alpha  Depth  Stencil  Accumulation  Color  can be divided into front and back for double buffering  Alpha  Depth  Stencil  Accumulation

Double Buffering

Animating Using Double Buffering  Request a double buffered color buffer glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE);  Clear color buffer  glClear(GL_COLOR_BUFFER_BIT);  Render Scene  Request swap of front and back buffers  glutSwapBuffers();  Repeat steps 2-4 for animation.  Request a double buffered color buffer glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE);  Clear color buffer  glClear(GL_COLOR_BUFFER_BIT);  Render Scene  Request swap of front and back buffers  glutSwapBuffers();  Repeat steps 2-4 for animation.

Depth Buffering

3D Coords --> Raster coords  Transformations  Clipping  Viewport transformation.  Transformations  Clipping  Viewport transformation.

GLUT Solids  Sphere  Cube  Cone  Torus  Dodecahedron  Octahedron  Tetrahedron  Icosahedron  Teapot  Sphere  Cube  Cone  Torus  Dodecahedron  Octahedron  Tetrahedron  Icosahedron  Teapot

glutSolidSphere and glutWireSphere  void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);  radius - The radius of the sphere.  slices - The number of subdivisions around the Z axis (similar to lines of longitude).  stacks - The number of subdivisions along the Z axis (similar to lines of latitude).  void glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);  radius - The radius of the sphere.  slices - The number of subdivisions around the Z axis (similar to lines of longitude).  stacks - The number of subdivisions along the Z axis (similar to lines of latitude).

glutSolidCube and glutWireCube  void glutSolidCube(GLdouble size);  size – length of sides  void glutSolidCube(GLdouble size);  size – length of sides

glutSolidCone and glutWireCone  void glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);  base - The radius of the base of the cone.  height - The height of the cone.  slices - The number of subdivisions around the Z axis.  stacks - The number of subdivisions along the Z axis.  void glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);  base - The radius of the base of the cone.  height - The height of the cone.  slices - The number of subdivisions around the Z axis.  stacks - The number of subdivisions along the Z axis.

glutSolidTorus and glutWireTorus  void glutSolidTorus(GLdouble innerRadius,GLdouble outerRadius, GLint nsides, GLint rings);  innerRadius - Inner radius of the torus.  outerRadius - Outer radius of the torus.  nsides - Number of sides for each radial section.  rings - Number of radial divisions for the torus.  void glutSolidTorus(GLdouble innerRadius,GLdouble outerRadius, GLint nsides, GLint rings);  innerRadius - Inner radius of the torus.  outerRadius - Outer radius of the torus.  nsides - Number of sides for each radial section.  rings - Number of radial divisions for the torus.

glutSolidDodecahedron and glutWireDodecahedron  void glutSolidDodecahedron(void);

glutSolidOctahedron and glutWireOctahedron.  void glutSolidOctahedron(void);

glutSolidTetrahedron and glutWireTetrahedron  void glutSolidTetrahedron(void);

glutSolidIcosahedron and glutWireIcosahedron  void glutSolidIcosahedron(void);

glutSolidTeapot and glutWireTeapot  void glutSolidTeapot(GLdouble size);  size - Relative size of the teapot.  void glutSolidTeapot(GLdouble size);  size - Relative size of the teapot.

Homework  Project part 2 due 2/19  Turn in a program that, at a minimum, draws your initial scene.  Project part 2 due 2/19  Turn in a program that, at a minimum, draws your initial scene.