CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS

Slides:



Advertisements
Similar presentations
Computer Graphics- SCC 342
Advertisements

CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
COMP 175 | COMPUTER GRAPHICS Remco Chang1/6103b – Shapes Lecture 03b: Shapes COMP 175: Computer Graphics February 3, 2015.
CMPE 466 COMPUTER GRAPHICS
CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
ADA: 15. Basic Math1 Objective o a reminder about dot product and cross product, and their use for analyzing line segments (e.g. do two segments.
General Physics (PHYS101)
Classes of Polygons Planar polygons Non-planar polygons Simple
Informationsteknologi Wednesday, November 7, 2007Computer Graphics - Class 51 Today’s class Geometric objects and transformations.
Advanced Computer Graphics Spring 2014

CS 450: Computer Graphics OVERVIEW OF POLYGONS
Computational Geometry & Collision detection
Introduction It is not uncommon for people to think of geometric figures, such as triangles and quadrilaterals, to be separate from algebra; however, we.
Chapter 4.1 Mathematical Concepts
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.
Computer Graphics using OpenGL, 3 rd Edition F. S. Hill, Jr. and S. Kelley Chapter Vector Tools for Graphics.
Class 25: Question 1 Which of the following vectors is orthogonal to the row space of A?
Chapter 2: Vectors Ian Parberry University of North Texas Fletcher Dunn Valve Software 3D Math Primer for Graphics and Game Development.
Vectors.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
CS 450: Computer Graphics 2D TRANSFORMATIONS
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
CSE554SimplificationSlide 1 CSE 554 Lecture 7: Simplification Fall 2014.
Definitions and Examples of Geometric Terms
Chapter 3. Vector 1. Adding Vectors Geometrically
2IV60 Computer Graphics Basic Math for CG
Geometric Intuition Randy Gaul. Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful.
Chapter 3 Vectors.
Mathematical Fundamentals
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
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.
Properties of Polygons The students will be able to describe the characteristics of a figure and to identify polygons.
Geometric Transformation. So far…. We have been discussing the basic elements of geometric programming. We have discussed points, vectors and their operations.
CS 450: COMPUTER GRAPHICS QUATERNIONS SPRING 2015 DR. MICHAEL J. REALE.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Part 6: Graphics Output Primitives (4) 1.  Another useful construct,besides points, straight line segments, and curves for describing components of a.
H.Melikyan/12001 Vectors Dr.Hayk Melikyan Departmen of Mathematics and CS
CS 325 Introduction to Computer Graphics 02 / 17 / 2010 Instructor: Michael Eckmann.
Methods and Solving Equations
CS 376 Introduction to Computer Graphics 02 / 16 / 2007 Instructor: Michael Eckmann.
1.1 Points, Lines and Planes
CSE554SimplificationSlide 1 CSE 554 Lecture 7: Simplification Fall 2013.
CSE554Fairing and simplificationSlide 1 CSE 554 Lecture 6: Fairing and Simplification Fall 2012.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
Chapter 3 Vectors. Vector quantities  Physical quantities that have both numerical and directional properties Mathematical operations of vectors in this.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
1 11. Polygons Polygons 2D polygons ( 다각형 ) –Polygon sides are all straight lines lying in the same plane 3D polyhedra ( 다면체 )  chap. 12 –Polyhedra.
In the name of God Computer Graphics Bastanfard. Curve Function(2) Other method is approximate it using a poly-line. Just locate a set of points along.
 Conjecture- unproven statement that is based on observations.  Inductive reasoning- looking for patterns and making conjectures is part of this process.
Computer Graphics Matrices
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
CLASSIFYING POLYGONS UNIT 1 LESSON 6. Classifying Polygons In geometry, a figure that lies in a plane is called a plane figure. A polygon is a closed.
 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)
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
Chapter 3 Lecture 5: Vectors HW1 (problems): 1.18, 1.27, 2.11, 2.17, 2.21, 2.35, 2.51, 2.67 Due Thursday, Feb. 11.
Vectors in the Plane 8.3 Part 1. 2  Write vectors as linear combinations of unit vectors.  Find the direction angles of vectors.  Use vectors to model.
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.
Math Fundamentals Maths revisit.
Lecture 03: Linear Algebra
Lecture 13 Clipping & Scan Conversion
CSE 411 Computer Graphics Lecture #2 Mathematical Foundations
Parallel and Perpendicular Lines/Triangles and Transformations
Game Programming Algorithms and Techniques
Polygons.
Year 7 Unit 1 Knowledge Organiser PLACE VALUE, DECIMALS & USING SCALES
Presentation transcript:

CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS Spring 2015 Dr. Michael J. Reale

NOTE: COUNTERCLOCKWISE ORDER Assuming: Right-handed system Vertices in counterclockwise order (looking at front of polygon)

FILL AREAS Fill area (or filled area) = area to be filled with color or pattern (or both) Usually surface of object Usually polygons

WHY POLYGONS? Why? Boundaries = linear equations (efficient fill algorithms) Can approximate most curved surfaces with polygons Shading easier (especially with triangles  single plane per triangle) Surface tessellation = approximating a curved surface with polygons More polygons  better detail, but more vertices/polygons to process Also called fitting the surface with a polygon mesh http://www.guru3d.com/articles-pages/radeon-hd-5870-review-test,7.html

POLYGON DEFINITIONS Polygon = a figure with 3 or more vertices connected in sequence by straight-line segments (edges or sides of the polygon) Most loose definition  any closed-polyline boundary More finicky definitions  contained in single plane, edges have no common points other than their endpoints, no three successive points collinear Standard polygon or simple polygon = closed-polyline with no crossing edges

DOES A POLYGON LIE IN A SINGLE PLANE? In computer graphics, polygon not always in same plane: Round-off error E.g., after transformations Fitting to surface makes non-planar polygons E.g., quad “bent” in half Thus, use triangles  single plane per triangle

DEGENERATE POLYGONS Degenerate polygons = often used to describe polygon with: 3 or more collinear vertices  generates a line segment E.g., in extreme case, triangle with no area Repeated vertex positions  some edges have length 0

CONVEX VS. CONCAVE Interior angle = angle inside polygon boundary formed by two adjacent edges By interior angle: Convex = all interior angles less than 180° Concave = one or more interior angles greater than or equal to 180° By looking at vertices compared to edge lines: Convex = for all edge lines, all other vertices are on one side Concave = for one or more edge lines, some of the vertices are on one side and some are on the other Also, one or more edge lines will intersect another edge

CONVEX VS. CONCAVE: CORNY MEMORY HOOK

DEALING WITH DEGENERATES AND CONCAVE POLYGONS OpenGL cannot deal with degenerate polygons or concave polygons  programmer must detect/preprocess them Degenerate polygons  detect and remove Concave polygons  detect and split into convex polygons

What’s your vector, victor? http://www.spudislunarresources.com/blog/wp-content/uploads/2013/03/Airplane.jpg What’s your vector, victor? A vector = (N x 1) or (1 x N) matrix (# of rows X # of columns) In computer graphics: N  usually 2, 3, or 4 (homogeneous coordinates) Use column vectors (N x 1) Components of the vector: 2D  x and y values 3D  x, y, and z values 4D  x, y, z, and w values Vector interpreted as: Location (w = 1) Direction (w = 0) Scalar = single value (or 1x1 vector)

LENGTH OF A VECTOR and THE ZERO VECTOR Use Euclidean distance for length: A vector with a length of zero is called the zero vector:

SCALING VECTORS Scalar times a vector = scalar times the components of the vector Example: multiply 5 by a 3D vector A

NORMALIZED VECTORS Normalize a vector = divide vector by its length ║v║  makes length equal to 1 Equivalent to multiplying vector by 1/║v║ Resulting vector is called a normalized vector WARNING: This is NOT the same as a NORMAL vector! Although normal vectors are often normalized.

ADDING/SUBTRACTING VECTORS Add/subtract vectors  add/subtract components Geometric interpretation: Adding  putting head of one vector on tail of the other Subtracting  gives direction from one endpoint to the other

DOT PRODUCT Result is a single number (i.e., scalar)  another name for the dot product is the scalar product Dot product of vector with itself = square of length of vector: Equivalent to: …where θ = smallest angle between the two vectors If the vectors are normalized, then:

DOT PRODUCT: CHECKING ANGLES Remember: DOT PRODUCT: CHECKING ANGLES Look at sign of dot product to check angle: (A · B) > 0  vectors pointing in similar directions (0 <= θ < 90°) (A · B) = 0  vectors are orthogonal (i.e., perpendicular to each other) (θ = 90°) (A · B) < 0  vectors pointing away from each other (90° < θ <= 180°) For normalized vectors, dot product ranges from [-1, 1]: (A · B) = 1  vectors pointing in the exact same direction (θ = 0°) (A · B) = -1  vectors pointing in the exact opposite direction (θ = 180°) (We’re going to use this trick for lighting calculations later  )

CROSS PRODUCT Also called vector product (results is a vector) Given two vectors U and V  gives vector W that is orthogonal (perpendicular) to both U and V U, V, and W form right-handed system! I.e., can use right-hand-rule on U and V (IN THAT ORDER) to get W Example: (X x Y) = Z axis! The length of W (= U X V) is equivalent to: …where again θ = smallest angle between U and V If U and V are parallel  θ = 0°  sin θ = 0  get zero vector for W!

CROSS PRODUCT: ORDER MATTERS! WARNING! ORDER MATTERS with the cross product! Property of anti-commutativity REMEMBER THE RIGHT-HAND-RULE!!!

COMPUTING THE CROSS PRODUCT: SARRUS’S SCHEME Follow diagonal arrows  for each arrow  multiply elements along arrow times sign at top ex = x axis, ey = y axis, ez = z axis

DETECTING AND SPLITTING CONCAVE POLYGONS There are 2 ways we can do this: Vector method Check interior angles using cross product Rotational method Rotate each edge in line with X axis  check if vertex below X axis

SPLITTING BY VECTOR METHOD Transform to XY plane (if necessary) Get edge vectors in counterclockwise order: For each pair of consecutive edge vectors, get cross product If concave  negative Z component  split polygon along first vector in cross product pair Have to intersect this line with other edges Repeat process with two new polygons NOTE: 3 successive collinear points anywhere  cross product becomes zero vector!

SPLITTING BY ROTATIONAL METHOD Transform to XY plane (if necessary) For each vertex Vk: Move polygon so that Vk is at the origin Rotate polygon so that Vk+1 is on the X axis If Vk+2 is below X axis  polygon is concave  split polygon along x axis Repeat concave test for each of the two new polygons Stop when we’ve checked all vertices

SPLITTING A CONVEX POLYGON Every 3 consecutive vertices  make triangle Remove middle vertex Keep going until down to last 3 vertices

PLANE EQUATION Need plane equation: Need normal of polygon: Collision detection, raytracing/raycasting, etc. Need normal of polygon: Lighting/shading Backface culling  don’t draw polygon facing away from camera General equation of a plane: (x,y,z) = any point on the plane A,B,C,D = plane parameters ON the plane  Ax + By + Cz + D = 0 BEHIND the plane  Ax + By + Cz + D < 0 IN FRONT OF the plane  Ax + By + Cz + D > 0

CALCULATING THE PLANE EQUATION Divide the formula by D Pick any 3 noncollinear points in the polygon Solve set of 3 simultaneous linear plane equations to get A/D, B/D, and C/D  use Cramer’s Rule

QUICK REVIEW: DETERMINANT OF A MATRIX

If THE POLYGON IS NOT CONTAINED IN A PLANE Either: Divide into triangles OR: Find approximating plane Divide vertices into subsets of 3 Get plane parameters for each subset Get average plane parameters

NORMAL VECTOR Normal vector = gives us orientation of plane/polygon Points towards OUTSIDE of plane From back face to front face Perpendicular to surface of plane Normal N = (A,B,C)  parameters from plane equation! Although it doesn’t have to be, the normal vector is often normalized (i.e., length = 1)

GETTING NORMAL AND PLANE EQUATION Solve for plane equation  normal = (A,B,C) OR Get normal from edges using cross-product  solve for D in plane equation V1, V2, and V3 = consecutive vertices in counterclockwise order: NOTE: Counterclockwise looking from outside the polygon towards inside

POINT-nORMAL PLANE EQUATION Given the normal N and any point on the plane, the following holds true: A related, alternative equation for a plane is the point-normal form: …where V is any 3D point

EXAMPLE