Our Friend the Dot Product

Slides:



Advertisements
Similar presentations
Affine Transformations Jim Van Verth NVIDIA Corporation
Advertisements

Collision Response Jim Van Verth
Linear Transformations and Matrices Jim Van Verth Lars M. Bishop
Vectors, Points, Lines and Planes Jim Van Verth Lars M. Bishop
CS 450: COMPUTER GRAPHICS LINEAR ALGEBRA REVIEW SPRING 2015 DR. MICHAEL J. REALE.
3D Geometry for Computer Graphics
Announcements. Structure-from-Motion Determining the 3-D structure of the world, and/or the motion of a camera using a sequence of images taken by a moving.
Rigid Body Dynamics Jim Van Verth
Fun with Vectors. Definition A vector is a quantity that has both magnitude and direction Examples?
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
Computational Geometry & Collision detection
Chapter 4.1 Mathematical Concepts
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Now Playing: My Mathematical Mind Spoon From Gimme Fiction Released May 10, 2005.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Vectors.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Scalar and Vector Fields
24. Dot Product of Vectors. What you’ll learn about  How to find the Dot Product  How to find the Angle Between Vectors  Projecting One Vector onto.
VECTORS AND THE GEOMETRY OF SPACE 12. VECTORS AND THE GEOMETRY OF SPACE So far, we have added two vectors and multiplied a vector by a scalar.
Multiplication with Vectors
Copyright © Cengage Learning. All rights reserved. 10 Analytic Geometry in Three Dimensions.
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
Chapter 9-Vectors Calculus, 2ed, by Blank & Krantz, Copyright 2011 by John Wiley & Sons, Inc, All Rights Reserved.
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)
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
Patrick Nichols Thursday, September 18, Linear Algebra Review.
Chapter 4.1 Mathematical Concepts
Vectors & Matrices Marq Singer
ME 2304: 3D Geometry & Vector Calculus
Vectors and the Geometry of Space
Copyright © Cengage Learning. All rights reserved. 12 Vectors and the Geometry of Space.
Scalars and Vectors Scalars are quantities that are fully described by a magnitude (or numerical value) alone. Vectors are quantities that are fully described.
6.837 Linear Algebra Review Patrick Nichols Thursday, September 18, 2003.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Mathematics for Graphics. 1 Objectives Introduce the elements of geometry  Scalars  Vectors  Points Develop mathematical operations among them in a.
Vectors CHAPTER 7. Ch7_2 Contents  7.1 Vectors in 2-Space 7.1 Vectors in 2-Space  7.2 Vectors in 3-Space 7.2 Vectors in 3-Space  7.3 Dot Product 7.3.
Elementary Linear Algebra Anton & Rorres, 9th Edition
Matthew Christian. About Me Introduction to Linear Algebra Vectors Matrices Quaternions Links.
Midterm Review  Five Problems 2-D/3-D Vectors, 2-D/3-D equilibrium, Dot Product, EoE, Cross Product, Moments  Closed Book & Note  Allowed to bring.
CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)
Chap. 5 Inner Product Spaces 5.1 Length and Dot Product in R n 5.2 Inner Product Spaces 5.3 Orthonormal Bases: Gram-Schmidt Process 5.4 Mathematical Models.
Chapter 3 Vectors. Vector quantities  Physical quantities that have both numerical and directional properties Mathematical operations of vectors in this.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
UW EXTENSION CERTIFICATE PROGRAM IN GAME DEVELOPMENT 2 ND QUARTER: ADVANCED GRAPHICS Math Review.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Copyright © Cengage Learning. All rights reserved. 12 Vectors and the Geometry of Space.
Computer Graphics Mathematical Fundamentals Lecture 10 Taqdees A. Siddiqi
Linear Algebra Review Tuesday, September 7, 2010.
Computer Graphics Lecture 11 2D Transformations I Taqdees A. Siddiqi
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry "Old Henry And His Old Aunt" Defined using right triangle  x y h.
1 Objective To provide background material in support of topics in Digital Image Processing that are based on matrices and/or vectors. Review Matrices.
Coordinatate systems are used to assign numeric values to locations with respect to a particular frame of reference commonly referred to as the origin.
1 MAC 2103 Module 4 Vectors in 2-Space and 3-Space I.
CHAPTER 3 VECTORS NHAA/IMK/UNIMAP.
13 VECTORS AND THE GEOMETRY OF SPACE.
Vectors Jeff Chastine.
Math 200 Week 3 - Monday Planes.
Lecture 03: Linear Algebra
Math review - scalars, vectors, and matrices
Game Programming Algorithms and Techniques
CHAPTER 3 VECTORS NHAA/IMK/UNIMAP.
Presentation transcript:

Our Friend the Dot Product Jim Van Verth (jim@essentialmath.com)

Essential Math for Games So… Why The Dot Product? Probably the single most important vector operation The Ginzu™ knife of graphics It slices, it dices, it has 1001 uses Understanding is a 3-D sword… So Define Utilize Essential Math for Games

Essential Math for Games Background Assume you know something about vectors Will be skipping some steps for time Just follow along Essential Math for Games

Essential Math for Games What is the Dot Product? One of a class of vector functions known as inner products Means that it satisfies various axioms Useful for dot product math Essential Math for Games

Definition #1: Coordinant-Free In Euclidean space, define dot product of vectors a & b as where || || == length  == angle between a & b a  b Essential Math for Games

Definition #2: Coordinant-Dependant By using Law of Cosines, can compute coordinate-dependant definition in 3-space: or 2-space: Essential Math for Games

Essential Math for Games Use #1: Measure Angles Look at def #1: Can rearrange to compute angle between vectors: A little expensive – cheaper tests available Essential Math for Games

Essential Math for Games Use #1: Measure Angles Rather than determining exact angle, can use sign to classify angle ||a|| and ||b|| are always non-negative, so sign depends on cos , therefore a • b > 0 if angle < 90° a • b = 0 if angle = 90° (orthogonal) a • b < 0 if angle > 90° Essential Math for Games

Essential Math for Games Angles: View Testing Simple view culling Suppose have view vector v and vector t to object in scene (t = o - e) If v • t < 0, object behind us, cull e v t o Essential Math for Games

Essential Math for Games Angles: View Testing Note: doesn’t work well for large objects objects close to view plane Best for AI, not rendering e v t o Essential Math for Games

Angles: Collision Response Have normal n (from object A to object B), relative velocity va-vb Three cases of contact: Separating (va-vb) • n < 0 Colliding (va-vb) • n > 0 Resting (va-vb) • n = 0 Essential Math for Games

Essential Math for Games Angles: View Cone Test against view cone – store cosine of view angle and compare If d • L < cos v, cull Nice for spotlights Must normalize ^ ^ ^ L v ^ d Essential Math for Games

Angles: Collinear Test Test for parallel vectors If v and w parallel & pointing same direction, v • w ~ 1 If v and w parallel & pointing opposite direction, v • w ~ -1 Has problems w/floating point, though And you have to normalize ^ ^ ^ ^ ^ ^ ^ ^ Essential Math for Games

Essential Math for Games Use #2: Projection Suppose want to project a onto b Is part of a pointing along b Represented as a  b Essential Math for Games

Essential Math for Games Use #2: Projection a From trig Now multiply by normalized b, so  b Essential Math for Games

Essential Math for Games Use #2: Projection So have If b is already normalized (often the case), then becomes Essential Math for Games

Projection: OBB Collision Idea: determine if separating plane between boxes exists Project box extent onto plane normal, test against projection btwn centers c a b av bv cv Essential Math for Games

Projection: OBB Collision To ensure maximum extents, take dot product using only absolute values Check against axes for both boxes, plus cross products of all axes See Gottschalk for more details Essential Math for Games

Essential Math for Games Use #2: Projection Can use this to break a into components parallel and perpendicular to b a b Essential Math for Games

Projection: Line-Point Distance ^ Line defined by point P and vector v Break vector w = Q – P into w and w|| w|| = (w  v) v ||w||2 = ||w||2 – ||w||||2 ^ ^ Q w w w|| P ^ v Essential Math for Games

Projection: Line-Point Distance Final formula: If v isn't normalized: Essential Math for Games

Use #3: Hidden Dot Products There are dot products everywhere… just need to know to look for them Examples: Plane equation Matrix multiplication Luminance calculation Essential Math for Games

Essential Math for Games Planes Defined by normal n = (a, b, c) point on plane P0=(x0, y0, z0) Plane equation ax+by+cz+d = 0 d=-(ax0 + by0 + cz0) Dot products! Essential Math for Games

Essential Math for Games Planes Why a dot product? Plane is all points P = (x, y, z) passing through P0 and orthogonal to normal Can express as n P0 P Essential Math for Games

Essential Math for Games Planes Plane is all points P = (x, y, z) such that Can rewrite as or Essential Math for Games

Essential Math for Games Planes Can use plane equation to test locality of point If n is normalized, gives distance to plane n ax+by+cz+d > 0 ax+by+cz+d = 0 ax+by+cz+d < 0 Essential Math for Games

Essential Math for Games Planes Project point to plane Assuming n normalized, n P v|| v P0 P’ Essential Math for Games

Essential Math for Games Planes Want to mirror point across a plane Take dot product of vector with normal Subtract twice from vector n v|| v -v|| v - 2v|| Essential Math for Games

Essential Math for Games Matrix Product or In general, element ABij is dot product of row i from A and column j from B Essential Math for Games

Essential Math for Games Matrix Product So what does this mean? Beats me… but it’s cool Essential Math for Games

Essential Math for Games Luminance Can convert RGB color to single ‘luminance’ value by computing In this case, a projection of sorts “Luminance” vector not normalized Essential Math for Games

Use #4: Perpendicular Dot Product 2D cross product, sort of Perpendicular takes 2D vector and rotates it 90 ccw Take another vector and dot it, get Looks like z term from cross product Essential Math for Games

Perpendicular Dot Product Result is So if you want to compute signed angle from v0 to v1, could do (works for 3D, too, just need to get length of cross product) Essential Math for Games

Perpendicular Dot Product Another use: sign of perp dot product indicates turning direction Have velocity v, direction to target d If v• d is positive, turn left If negative, turn right v v d d v v Essential Math for Games

Essential Math for Games Conclusion Dot product is cool Dot product has many uses Use it heavily and often Essential Math for Games

Essential Math for Games References Van Verth, James M. and Lars Bishop, Essential Mathematics for Games and Interactive Applications, Morgan Kaufmann, 2004. Anton, Howard and Chris Rorres, Elementary Linear Algebra, 7th Ed, Wiley & Sons, 1994. Axler, Sheldon, Linear Algebra Done Right, Springer Verlag, 1997. Essential Math for Games