1 / 42

Vectors, Points, Lines and Planes

Vectors, Points, Lines and Planes. Jim Van Verth (jim@essentialmath.com) Lars M. Bishop (lars@essentialmath.com). Geometric Representation. Problem Represent geometric data in computer? Solution Vectors and points Can represent most abstract objects as combinations of these

felix
Download Presentation

Vectors, Points, Lines and Planes

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. Vectors, Points, Lines and Planes Jim Van Verth (jim@essentialmath.com) Lars M. Bishop (lars@essentialmath.com)

  2. Geometric Representation • Problem • Represent geometric data in computer? • Solution • Vectors and points • Can represent most abstract objects as combinations of these • E.g. lines, planes, polygons Essential Math for Games

  3. What Is a Vector? • Geometric object with two properties • direction • length (if length is 1, is unit vector) • Graphically represented by Essential Math for Games

  4. Scale • Graphically • change length of vector v by  Essential Math for Games

  5. b a a + b Addition • Graphically • put tail of second vector at head of first • draw new vector from tail of first to head of second Essential Math for Games

  6. Algebraic Vectors • Algebraically, vectors are more than this • Any entity that meets certain rules (lies in vector space) can be called ‘vector’ • Ex: Matrices, quaternions, fixed length polynomials • Mostly mean geometric vectors, however Essential Math for Games

  7. Vector Space • Set of vectors related by +,· • Meet rules • v + w = w + v (commutative +) • (v + w) + u = v + (w + u) (associative +) • v + 0 = v (identity +) • v + (-v) = 0 (inverse +) • () v =  (v) (associative ·) • (+)v = v + v (distributive ·) • (v + w) = v + w(distributive ·) Essential Math for Games

  8. Number Spaces • Cardinal – Positive numbers, no fractions • Integer – Pos., neg., zero, no fractions • Rational – Fractions (ratios of integers) • Irrational – Non-repeating decimals (,e) • Real – Rationals+irrationals • Complex – Real + multiple of -1 a+bi Essential Math for Games

  9. Real Vector Spaces • Usually only work in these • Rn is an n-dimensional system of real numbers • Represented as ordered list of real numbers (a1,…,an) • R3is the 3D world, R2is the 2D world Essential Math for Games

  10. Linear Combination • Combine set of n vectors using addition and scalar multiplication • v = 1v1 + 2v2 + … + nvn • Collection of all possible linear combinations for given v1… vn is called a span • Linear combination of 2 perpendicular vectors span a plane Essential Math for Games

  11. Linear Dependence • A system of vectors v1, … ,vnis called linearly dependant if for at least one vi • vi = 1v1 +…+ i-1vi-1 + i+1vi+1 +…+ nvn • Otherwise, linearly independent • Two linearly dependant vectors are said to be collinear • I.e. w = .v • I.e. they point the “same” direction Essential Math for Games

  12. Vector Prerequisites Linear Dependence • Example • Center vector can be constructed from outer vectors Essential Math for Games

  13. Vector Basis • Ordered set of n lin. ind. vectors •  = {v1,v2, …, vn} • Span n-dimensional space • Represent any vector as linear combo • v = 1v1 + 2v2 + … + nvn • Or just components • v = (1,2, …, n) Essential Math for Games

  14. v3 v2 v1 Vector Representation • 3D vector vrepresented by (x, y,z) • Use standard basis { i, j, k } • Unit length, perpendicular (orthonormal) • v = xi + yj + zk • Number of units in each axis direction Essential Math for Games

  15. Vector Operations • Addition: +,- • Scale: · • Length: ||v|| • Normalize: Essential Math for Games

  16. Addition • Add a to b b a a + b Essential Math for Games

  17. Scalar Multiplication • change length of vector v by  Essential Math for Games

  18. Length • Length • ||v|| gives length (or Euclideannorm) of v • if ||v|| is 1, v is called unit vector • usually compare length squared • Normalize • v scaled by 1/||v|| gives unit vector Essential Math for Games

  19. Vector Operations • Games tend to use most of the common vector operations • Addition, Subtraction • Scalar multiplication • Two others are extremely common: • Dot product • Cross product Essential Math for Games

  20. Dot product • Also called inner product, scalar product a  b Essential Math for Games

  21. Dot Product: Uses • a • a equals ||a||2 • can test for collinear vectors • if a and b collinear & unit length, |a • b| ~ 1 • Problems w/floating point, though • can test angle/visibility • a • b > 0 if angle < 90° • a • b = 0 if angle = 90° (orthogonal) • a • b < 0 if angle > 90° Essential Math for Games

  22. Dot Product: Example • Suppose have view vector v and vector t to object in scene (t = o - e) • If v • t < 0, object behind us, don’t draw e v t o Essential Math for Games

  23. Dot Product: Uses • Projection of a onto b is a b Essential Math for Games

  24. Dot Product: Uses • Example: break a into components collinear and perpendicular to b a b Essential Math for Games

  25. Cross Product • Cross product: definition • returns vector perpendicular to a and b • right hand rule • length = area of parallelogram c b a Essential Math for Games

  26. Cross Product: Uses • gives a vector perpendicular to the other two! • ||a  b|| = ||a|| ||b|| sin() • can test collinearity • ||a  b|| = 0 if a and b are collinear • Better than dot – don’t have to be normalized Essential Math for Games

  27. Other Operations • Several other vector operations used in games may be new to you: • Scalar Triple Product • Vector Triple Product • These are often used directly or indirectly in game code, as we’ll see Essential Math for Games

  28. Scalar Triple Product • Dot product/cross product combo • Volume of parallelpiped • Test rotation direction • Check sign u v w Essential Math for Games

  29. Triple Scalar Product: Example • Current velocity v, desired direction d on xy plane • Take • If > 0, turn left, if < 0, turn right v v  d d d v  d v Essential Math for Games

  30. Vector Triple Product • Two cross products • Useful for building orthonormal basis • Compute and normalize: Essential Math for Games

  31. Points • Points are positions in space — anchored to origin of coordinate system • Vectors just direction and length — free-floating in space • Can’t do all vector operations on points • But generally use one class in library Essential Math for Games

  32. Point-Vector Relations • Two points related by a vector • (Q - P) = v • P + v = Q Q v P Essential Math for Games

  33. Affine Space • Vector, point related by origin • (P - O) = v • O + v = P • Vector space, origin, relation between them make an affine space P e3 v O e2 e1 Essential Math for Games

  34. Cartesian Frame • Basis vectors {i, j, k}, origin (0,0,0) • 3D point Prepresented by (px, py, pz) • Number of units in each axis direction relative to origin pz o px py Essential Math for Games

  35. Affine Combination • Like linear combination, but with points • P = a1P1 + a2P2 + … + anPn • a1,…,an barycentric coord., add to 1 • Same as point + linear combination • P = P1 + a2 (P2-P1) + … + an (Pn-P1) • If vectors (P2-P1), …, (Pn-P1) are linearly independent, {P1, …, Pn} called a simplex (think of as affine basis) Essential Math for Games

  36. Convex Combination • Affine combination with a1,…,an between 0 and 1 • Spans smallest convex shape surrounding points – convex hull • Example: triangle Essential Math for Games

  37. Points, Vectors in Games • Points used for models, position • vertices of a triangle • Vectors used for velocity, acceleration • indicate difference between points, vectors Essential Math for Games

  38. Parameterized Lines • Can represent line with point and vector • P + tv • Can also represent an interpolation from P to Q • P + t(Q-P) • Also written as (1-t)P + tQ Q v P Essential Math for Games

  39. Planes • 2 non-collinear vectors span a plane • Cross product is normaln to plane n Essential Math for Games

  40. Planes • Defined by • normal n = (A, B, C) • point on plane P0 • Plane equation • Ax+By+Cz+D = 0 • D=-(A·P0x + B·P0y + C·P0z) Essential Math for Games

  41. 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

  42. References • Anton, Howard and Chris Rorres, Elementary Linear Algebra, 7th Ed, Wiley & Sons, 1994. • Axler, Sheldon, Linear Algebra Done Right, Springer Verlag, 1997. • Blinn, Jim, Notation, Notation, Notation, Morgan Kaufmann, 2002. Essential Math for Games

More Related