1 / 16

Geometric Objects and Transformations

Geometric Objects and Transformations. Chun-Yuan Lin The contexts of this slide is similar to Chapter 5-Geometric Transformations. Scalar, Points and Vectors (1). Geometric Objects Scalar, points and vectors Coordinate-Free Geometry The Mathematical View-Vector and Affine Spaces.

dwitcher
Download Presentation

Geometric Objects and Transformations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Geometric Objects and Transformations Chun-Yuan Lin The contexts of this slide is similar to Chapter 5-Geometric Transformations CG

  2. Scalar, Points and Vectors (1) • Geometric Objects • Scalar, points and vectors • Coordinate-Free Geometry • The Mathematical View-Vector and Affine Spaces CG

  3. Scalar, Points and Vectors (2) • The Computer Science View • Abstract data types (ADT) • Geometric ADTs • Lines • Affine Sums • Convexity CG

  4. Scalar, Points and Vectors (3) • Dot and Cross Products • Planes CG

  5. Three-Dimensional Primitives • Three features characterize three-dimensional objects that fit with existing graphics hardware and software. • The objects are described by their surfaces and can be thought of as being hollow. • The objects can be specified through a set of vertices in three dimensions. • The objects either are composed of or can approximated by flat, convex polygons. CG

  6. Coordinate Systems and Frames • Representation and N-tuples • Change of coordinate systems • Example Change of Representation • Homogeneous Coordinates • Example Change in Frames • Working with Representations CG

  7. Frames in OpenGL • For most of geometric problems, we usually go from one frame to another by a sequence of geometric transformations such as rotations, translations and scales. CG

  8. Modeling a Color Cube (1) • Modeling the faces • The cube is as simple a three-dimensional objects as we might expect to model and display. • There are several ways to model it. Example: GLfloat vertices[8][3]= {{}, {},{},{},{},{},{},{}}; • We can adopt a more object-orient form . typedef GLfloat point3[3]; point3 vertices[8]= {{}, {},{},{},{},{},{},{}}; CG

  9. Modeling a Color Cube (2) • We can then use the list of points to specify the face of the cube. For one face: glBegin(GL_POLYGON); glVertex3fv (vertices[0]); glVertex3fv (vertices[3]); glVertex3fv (vertices[2]); glVertex3fv (vertices[1]); glEnd(); CG

  10. Modeling a Color Cube (3) • Inward- and Outward-Pointing Faces • We call a face outward facing if the vertices are traversed in a counterclockwise order when the face is viewed from the outside. (right-hand rule) • Data structures for Object Representation glBegin(GL_POLYGON) glBegin(GL_QUADS) CG

  11. Modeling a Color Cube (4) • Vertex list CG

  12. Modeling a Color Cube (5) • The color cube • We assign a color for the face using the index of the first vertex. • Bilinear Interpolation CG

  13. GLfloat vertices[8][3] = {{-1.0,-1.0,-1.0},{1.0,-1.0,-1.0}, {1.0,1.0,-1.0}, {-1.0,1.0,-1.0}, {-1.0,-1.0,1.0}, {1.0,-1.0,1.0}, {1.0,1.0,1.0}, {-1.0,1.0,1.0}}; GLfloat colors[8][3] = {{0.0,0.0,0.0},{1.0,0.0,0.0}, {1.0,1.0,0.0}, {0.0,1.0,0.0}, {0.0,0.0,1.0}, {1.0,0.0,1.0}, {1.0,1.0,1.0}, {0.0,1.0,1.0}}; void quad(int a, int b, int c, int d) { glBegin(GL_POLYGON); 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(); } void colorcube() { 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); } CG

  14. Modeling a Color Cube (6) • Vertex Arrays • Vertex arrays provide a method for encapsulating the information in the data structure such that we can draw polyhedral objects with only a few function calls. glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(3, GL_FLOAT,0,vertices); glColorPointer(3,GL_FLOAT,0, colors); 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}; CG

  15. Modeling a Color Cube (7) • We can render the cube through use of the arrays. glDrawElements(GLenum type, GLsize n, GLenum format, void *pointer) example: for(i=0;i<6;i++) glDrawElements(GL_POLYGON, 4, GL_UNSIGNED BYTE, &cubeIndices[4*I]); Or glDrawElements(GL_QUADS, 24, GL_UNSIGNED BYTE, cubeIndices); CG

  16. Affine Transformations Translation, Rotation and Scaling Transformations in Homogeneous Coordinates Concatenation of Transformations OpenGL Transformation Matrices CG

More Related