1 / 33

Lecture 03b: Shapes

Lecture 03b: Shapes. COMP 175: Computer Graphics January 28, 2014. Quick Review of Linear Algebra. What is a cross product? How do you find the cross product? Different ways to think about the cross product? What is a dot product? How do you find the dot product?

dewey
Download Presentation

Lecture 03b: Shapes

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. Lecture 03b:Shapes COMP 175: Computer Graphics January 28, 2014

  2. Quick Review of Linear Algebra • What is a cross product? • How do you find the cross product? • Different ways to think about the cross product? • What is a dot product? • How do you find the dot product? • Different ways to think about the dot product? • Given two vectors A, B, show that the cross product N is orthogonal to A and B. • Points vs. Vectors • What are basis vectors? • In 2D, what 2 vectors cannot be basis vectors? • What is: • a unit vector • a normal vector • a null vector? • Vector math: • Add, subtract, multiple (by scalar) • Normalize a vector

  3. 2D Object Definition • Lines and Polyline • Polyline: lines drawn between ordered points • Polygon • If the first and last points of a polyline are the same point, then the polyline is said to be “closed”, and that the closed polyline forms a polygon • Self-intersected polyline not closed, simple polyline simple polygon, closed polyline not simple polygon, closed polyline

  4. 2D Object Definition • Convex and Concave polygons • Convex: for every pair of points inside the polygon, the line between them is entirely inside the polygon • Concave: for some pair of points inside the polygon, the line between them is not entirely inside the polygon. Not convex. convex concave

  5. 2D Object Definition • Why is a convex polygon so awesome?

  6. 2D Object Definition • Why is a convex polygon so awesome? • Center of mass • Tessellation • Subdivision • Fixed boundary • Exactly two intersections • All diagonals are within the boundary • Tessellation -> computing the area • Every interior angle is less than 180 • Etc.

  7. Special Polygons • Circle • Set of all points equidistant from one point called the center • The distance from the center is the radius r • The equation for a circle centered at (0, 0) is r2 = x2 + y2 Rectangle Triangle Square (x, y) (0, y) r (0, 0) (0, x)

  8. 6 6 5 5 4 4 3 3 2 2 1 1 0 0 1 2 3 4 5 6 7 8 9 10 10 1 2 3 4 5 6 7 8 9 2D Object Definition • A circle can be approximated by a polygon with many sides. • Axis aligned ellipse: a circle scaled in the x and/or y direction

  9. Representing Shapes • Vertex and Edge tables • General purpose, minimal overhead, reasonably efficient • Each vertex listed once • Each edge is an ordered pair of indices to the vertex list E3 V4 E2 V2 V3 E4 E1 E0 V0 V1

  10. Triangle Meshes • Most common representation of shape in three dimensions • All vertices of triangle are guaranteed to lie in one plane • (not true for quadrilaterals or other polygons) • Uniformity makes it easy to perform mesh operations such as subdivision, simplification, transformation etc. • Many different ways to represent triangular meshes

  11. Triangular Mesh Representation • Vertex, Face, (and Normal) Tables v4 v7 f11 v8 f10 f8 f9 v6 f0 v5 f2 f1 f3 v0 v1 v2

  12. Questions?

  13. Normals

  14. Calculating Normal

  15. 3D Barn Shape

  16. 3D Barn Shape

  17. 3D Barn Shape

  18. Other Possible Encodings • 3D meshes can be represented as vertices, (edges), faces, and normals • Are there other ways to encode 3D meshes?

  19. Parametric Shapes

  20. 2.5D Objects • 2.5D objects are 3D objects that are “protrusions” or “extensions” of 2D shapes (i.e., 2D shape + height)

  21. 3D Extrusions

  22. 3D Extrusions • A spring can be described in Cartesian coordinate system as: • Or in cylindrical coordinate as:

  23. Surfaces from Revolutions

  24. Technically... • We can think of the shapes in assignment 2 the same way... ““Vertices in Motion” • So we can make 3D shapes out of 2D and 1D primitives

  25. Questions?

  26. GL Normal • These two have the same number of quads… • What is the difference?

  27. GL Normal

  28. GL Normal glNormal3f(nx, ny, nz); glBegin(GL_QUADS); glVertex3f(x1, y1, z1); glVertex3f(x2, y2, z2); glVertex3f(x3, y3, z3); glVertex3f(x4, y4, z4); glEnd();

  29. GL Normal glBegin(GL_QUADS); glNormal3f(nx1, ny1, nz1); glVertex3f(x1, y1, z1); glNormal3f(nx2, ny2, nz2); glVertex3f(x2, y2, z2); glNormal3f(nx3, ny3, nz3); glVertex3f(x3, y3, z3); glNormal3f(nx4, ny4, nz4); glVertex3f(x4, y4, z4); glEnd();

  30. GL Normal • What are the normals? • For a circle / sphere? • For a cube? • For a cylinder? • For a cone? • How do you define what a normal is?

  31. GL Normal • What are the normals? • For a circle / sphere? • For a cube? • For a cylinder? • For a cone? • Thinking of the normal of a curved surface as the normal to the tangent plane

  32. Exercise • Write a render function that takes in two parameters, radius and slices, and produces a 2D circle drawn as a set of polylines (assume centered at (0,0)), with a defined normal for each vertex • That is, fill in this function: void drawCircle2D(float radius, int slices) { : : glBegin (...); for (inti=0; i<...) { : : glNormal2f(...); glVertex2f(...); } glEnd(); }

  33. Questions?

More Related