Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Geometric Intuition Randy Gaul

2 Vectors, Points and Basis Matrices Rotation Matrices Dot product and how it’s useful Cross product and how it’s useful Extras Talk Outline

3 Matrix multiplication How to apply dot/cross product Vector normalization Basic understanding of sin/cos Basic idea of what a plane isplane Prerequisites

4 Formal definition – Input or output from a function of vector algebravector algebra Informal definition – Scalar components representing a direction and magnitude (length) – Vectors have no “location” Vectors

5 Points and Vectors A point P and Q is related to the vector V by: – P – Q = V This implies that points can be translated by adding vectors

6 Points and Vectors (2) Lets define an implied point O – O represents the origin Any point P can be expressed with a vector V: – P = O + V Vectors point to points, when relative to the origin!

7 Standard Euclidean Basis (called E 3 ) – Geometrically the x, y and z axes Euclidean Basis

8 Given 3 scalars i, j and k, any point in E 3 can be represented Euclidean Basis (2)

9 Linear Combination Suppose we have a vector V – Consists of 3 scalar values – Below V written in “shorthand” notation

10 Linear Combination (2) V can be written as a linear combination of E 3 – This is the “longhand” notation of a vector

11 Basis Matrices E 3 is a basis matrix – Many matrices can represent a basis Any vector can be represented in any basis http://en.wikipedia.org/wiki/Change_of_basis Note: Different i, j and k values are used on left and right

12 Rotation Matrices A rotation matrix can rotate vectors – Constructed from 3 orthogonal unit vectors – Can be called an “orthonormal basis” E 3 is a rotation matrix!

13 Rotation Matrices (2) Rotation matrices consist of an x, y and z axis – Each axis is a vector X y z

14 Rotation Matrices (3) Multiplying a rotation and a vector rotates the vector This is a linear combination

15 Dot Product Comes from law of cosineslaw of cosines Full derivation herehere For two vectors u and v:

16 Shortest Angle Between 2 Vectors Assume u and v are of unit length Result in range of 0, 1 No trig functions required

17 How Far in a Given Direction? Given point P and vector V – How far along the V direction is P? P V x y

18 How Far in a Given Direction? (2)

19 Planes Here’s the 3D plane equation

20 Planes Here’s the 3D plane equation WAIT A SECOND

21 Planes Here’s the 3D plane equation WAIT A SECOND THAT’S THE DOT PRODUCT

22 Planes (2) a, b and c form a vector, called the normal d is magnitude of the vector – Represents distance of plane from origin

23 Planes (3)

24 Planes and the Dot Product

25 Planes and the Dot Product (2) x y P plane

26 Signed Distance P to Plane

27 Project P onto Plane x y P plane

28 Rotation Matrices and Dot Product Given matrices A and B A * B is to dot the rows of A with columns of B Lets assume A and B are rotation matrices http://en.wikipedia.org/wiki/Matrix_multiplication

29 Rotation Matrices and Dot Product (2)

30 Rotation Matrices and Dot Product (3)

31 Rotation Matrices and Dot Product (4)

32 Rotation Matrices and Dot Product (5)

33 Point in Convex Hull Test if point is inside of a hull – Compute plane equation of hull faces – Compute distance from plane with plane equation – If all distances are negative, point in hull – If any distance is positive, point outside hull Works in any dimension Can by used for basic frustum culling

34 Point in OBB An OBB is a convex hull! – Hold your horses here… Lets rotate point P into the frame of the OBB – OBB is defined with a rotation matrix, so invert it and multiply P by it – P is now in the basis of the OBB The problem is now point in AABB

35 Point in Cylinder Rotate cylinder axis to the z axis Ignoring the z axis, cylinder is a circle on the xy plane Test point in circle in 2D – If miss, exit no intersection Get points A and B. A is at top of cylinder, B at bottom See if point’s z component is less than A’s and greater than B’s – Return intersection No intersection

36 Bumper Car Damage? Two bumper cars hit each other One car takes damage How much damage is dealt, and to whom?

37 Bumper Car Damage Answer Take vector from one car to another, T Damage dealt: – 1.0 - Abs( Dot( velocity, T ) * collisionDamage )

38 http://www.ra ndygaul.net/20 14/07/23/dista nce-point-to- line-segment/

39

40 Visualization in 2D C P

41 Cross Product Operation between vectors Produces a vector orthogonal to both input vectors

42 Cross Product Handedness http://en.wikipedia.org/wiki/Cross_product

43 Cross Product Details http://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Cross_product.gif/2 20px-Cross_product.gif

44 Plane Equation from 3 Points Given three points A, B and C Calculate normal with: Cross( C – A, B – A ) Normalize normal Compute offset d: dot( normal, A (or B or C) )

45 Compute distance A to Plane: da Compute distance B to Plane: db If da * db < 0 – Intersection = A + (da / (da – db)) * (B – A) Else – No intersection

46

47 P normal

48 Affine Transformations Given matrix A, point x and vector b An affine transformation is of the form: – Ax + b

49 Affine Transformations Given 3x3 matrix A, point x and vector b An affine transformation is of the form: – Ax + b With a 4x4 matrix we can represent Ax + b in block formation:

50 Translation Construct an affine transformation such that when multiplied with a point, translates the point by the vector b I is the identity matrix, and means no rotation (or scaling) occurs

51 Translation (2) The 1 is important, it means it is a point If we had a zero here b wouldn’t affect x

52 Translation (3) Proof that translation doesn’t affect vectors: – Translate from P to Q by T P – Q = T = (P + T) – (Q + T) = (P – Q) + (T – T) = P – Q

53 Rotation Orthonormal basis into the top left of an affine transformation, without any translation vector:

54 Scaling Given scaling vector S Take the matrix A Scale A’s x axis’ x component by S 0 Scale A’s y axis’ y component by S 1 Scale A’s z axis’ z component by S 2

55 Scaling (2)

56 Camera - LookAt

57 Camera – LookAt (2) Won’t work when player tries to look straight up or down – Parallel vectors crossed result in the zero vector Possible solutions: – Snap player’s view away from up/down – Use an if statement and cross with a different up vector – More solutions exist!

58 Barycentric Coordinates Slightly out of scope of this presentation See Erin Catto’s GDC 2010 lecture Idea: – Like a linear combination, try affine combinations of points Useful for: – Voronoi region identification, collision detection, certain graphics or shader effects


Download ppt "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."

Similar presentations


Ads by Google