Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Vector Tools

1,332 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Vector Tools

  1. 1. VECTOR TOOLS By Abdul Ghaffar
  2. 2. Contents <ul><ul><li>Vector spaces and affine spaces 4.1, 4.2 (Self Study) </li></ul></ul><ul><ul><li>Operations with vectors 4.2.1 (Self Study) </li></ul></ul><ul><ul><li>Linear combination of vectors 4.2.2 </li></ul></ul><ul><ul><li>Dot product 4.3 (Self Study </li></ul></ul><ul><ul><li>Angle between two vectors 4.3.2 (Self Study) </li></ul></ul><ul><ul><li>Cross product 4.4 (Self Study) </li></ul></ul><ul><ul><li>Point normal for a line and plane 4.5.6 </li></ul></ul><ul><ul><li>Polygon intersection problems 4.8 </li></ul></ul><ul><ul><li>Scalar triple product A2.2.2 </li></ul></ul>
  3. 3. Review of Vector Difference b/w two points is a vector V=Q-P Sum of a point and a vector is a point Q=P+V
  4. 4. Operations with vectors
  5. 5. Linear combination of vectors <ul><li>A Linear combination of the m vectors v1.v2,…,vm is a vector form </li></ul><ul><li>w=a1v1+a2v2+…..+a m v m where a are scalars. </li></ul><ul><li>It will also be an affine combination if </li></ul><ul><li>a1+a2+….+am=1 </li></ul><ul><li>and a convex combination if all coefficients are nonnegative </li></ul><ul><li>=> ai >= 0, for i=1,….,m </li></ul>
  6. 6. Linear combination of vectors <ul><li>Set of all convex combinations of two vectors v1 and v2 is the set of all vectors </li></ul><ul><li>v =(1-a)v1+av2 or v=v1+a(v1-v2) </li></ul><ul><li>For three vectors the convex combination will be </li></ul><ul><li>v = a1v1 + a2v2 + (1-a1-a2 ) v3 </li></ul><ul><li>as shown as dark region in part b of fig. </li></ul>
  7. 7. The Dot Product <ul><li>The Dot Product of d of two n-dimensional vectors V=(v1,v2,…,vn) and W=(w1,w2,…wn) is denoted as V.W and has the value </li></ul><ul><li>Angle between two vectors is calculated as </li></ul><ul><li>b.c=|b||c| cos(  ) </li></ul>
  8. 8. Chapter 4: Vector Tools <ul><li>4.5 Representation of Key Geometric Objects </li></ul><ul><ul><li>4.5.1 Coordinate Systems and Coordinate Frames </li></ul></ul><ul><ul><ul><li>Points: location, no size, no direction </li></ul></ul></ul><ul><ul><ul><li>Vectors: size, direction, no location </li></ul></ul></ul><ul><ul><ul><li>A coordinate system is located in a world . </li></ul></ul></ul><ul><ul><ul><li>Coordinate frame: specific origin  , and 3 unit vectors a,b,c . </li></ul></ul></ul>
  9. 9. Chapter 4: Vector Tools <ul><ul><ul><li>v = v 1 a + v 2 b + v 3 c </li></ul></ul></ul><ul><ul><ul><li>Vector p-  = p 1 a + p 2 b + p 3 c </li></ul></ul></ul><ul><ul><ul><li>P =  + p 1 a + p 2 b + p 3 c where v and p are some numbers </li></ul></ul></ul><ul><ul><li>Homogeneous Representation of Point, Vector </li></ul></ul><ul><ul><ul><li>v = ( a,b,c,  ) </li></ul></ul></ul><ul><ul><ul><li>P = ( a,b,c,  ) </li></ul></ul></ul><ul><ul><ul><li>Note: OpenGL uses 4D homogeneous coordinates by default. </li></ul></ul></ul>
  10. 10. 4.5.4 Tweening (morphing) <ul><ul><li>P1(t)=(1-t)Ai+tBi </li></ul></ul>
  11. 11. Chapter 4: Vector Tools <ul><li>4.5.6 Representing Lines and Planes </li></ul><ul><ul><li>Line, line segment, ray </li></ul></ul><ul><ul><li>Parametric representation of line: L(t) = C + b t </li></ul></ul><ul><ul><li>Point normal form for line (implicit) </li></ul></ul><ul><ul><ul><li>Given line L through C and B, what is point normal form? </li></ul></ul></ul><ul><ul><ul><li>(B-C)  . (R-C) = 0 where R any point on line. </li></ul></ul></ul>
  12. 12. Chapter 4: Vector Tools <ul><li>Planes in 3D Space </li></ul><ul><ul><li>Parametric Representation of a Plane </li></ul></ul><ul><ul><ul><li>P(s,t) = C + a s + b t or </li></ul></ul></ul><ul><ul><ul><li>P(s,t) = sA + tB + (1-s-t)C </li></ul></ul></ul>
  13. 13. Point normal form <ul><li>For line </li></ul><ul><li>fx + gy = 1 </li></ul><ul><li>or (f,g).(g,y)=1 as dot Product </li></ul><ul><li>=> point normal form will be </li></ul><ul><li>n. (R-C) = 0 </li></ul><ul><li>where n can be found as </li></ul><ul><li>n = b  = B-C </li></ul>
  14. 14. Point normal form <ul><li>For Plane </li></ul><ul><ul><li>If R=(x,y,z) is any point on the plane </li></ul></ul><ul><ul><li>And n=(nx,ny,nz) is normal to the plane at point B then </li></ul></ul><ul><ul><li>n. ( R – B) = 0 </li></ul></ul><ul><ul><li>Which is the required form for the plane </li></ul></ul>
  15. 15. Chapter 4: Vector Tools <ul><li>Planar Patches </li></ul>
  16. 16. Chapter 4: Vector Tools <ul><li>4.6 Finding the Intersection of 2 Line Segments </li></ul><ul><ul><li>Parametric representations: </li></ul></ul><ul><ul><ul><li>AB(t) = A + bt </li></ul></ul></ul><ul><ul><ul><li>CD(u) = C + du where t and u are is times </li></ul></ul></ul><ul><ul><li>Intersection of lines AB and CD will be at time u=t , as </li></ul></ul><ul><ul><li>A + b t = C + d u, or b t = c + d u, or d  . b t = d  . c </li></ul></ul>Vectors : b=A-B d=C-D c=A-C
  17. 17. Chapter 4: Vector Tools <ul><ul><li>Case 1: d  . b not zero </li></ul></ul><ul><ul><ul><li>t = ( d  . c)/(d  . b) </li></ul></ul></ul><ul><ul><ul><li>u = ( b  . c)/(d  . b) </li></ul></ul></ul><ul><ul><ul><li>Intersection point I = A + (( d  . c)/(d  . b))b if 0 < t,u < 1 </li></ul></ul></ul><ul><ul><li>Case 2: d  . b zero : Lines are parallel </li></ul></ul><ul><li>4.6.1 Application of Line Intersections: Circle through 3 points : Selfstudy. </li></ul>
  18. 18. Intersections of Lines with Planes; Clip <ul><li>Line parametric representation; plane point normal form. </li></ul><ul><ul><li>As point normal form of the plane is </li></ul></ul><ul><ul><li>n.(P-B)=0 </li></ul></ul><ul><ul><li>If line hits the plane at P then P = A+ct hit </li></ul></ul><ul><ul><li>=> n.( A+ct hit – B) =0 </li></ul></ul><ul><ul><li>=> t hit = ( n . (B-A))/( n . c ) </li></ul></ul>
  19. 19. Chapter 4: Vector Tools <ul><ul><li>If n . c > 0 : ray aimed along with normal </li></ul></ul><ul><ul><li>If n . c < 0 : ray aimed counter to normal </li></ul></ul><ul><ul><li>If n . c = 0 : ray parallel to line </li></ul></ul><ul><li>4.8 Polygon Intersection Problems </li></ul>
  20. 20. Chapter 4: Vector Tools <ul><ul><li>Is given point P inside or outside the object? </li></ul></ul><ul><ul><li>Where does a given ray R first intersect the object? </li></ul></ul><ul><ul><li>Which part of given line L lies inside object, and which part outside? </li></ul></ul><ul><li>4.8.1 Convex Polygons and Polyhedra </li></ul><ul><ul><li>Convex polygon described by bounding lines </li></ul></ul><ul><ul><li>Convex polyhedron described by bounding planes </li></ul></ul>
  21. 21. Chapter 4: Vector Tools <ul><ul><li>Inside halfspace contains all points of polygon; outside halfspace shares no points with polygon. </li></ul></ul><ul><li>4.8.2 Ray Intersection, Clipping for Convex Polygons </li></ul><ul><ul><li>The Intersection problem: Use ray/line intersection solution, and calculate </li></ul></ul><ul><ul><ul><li>Entering hit point A+ c t in and </li></ul></ul></ul><ul><ul><ul><li>Exiting hit point A + c t out </li></ul></ul></ul><ul><ul><ul><li>Ray inside polygon for [t in ,t out ] </li></ul></ul></ul>
  22. 22. The Clipping problem <ul><ul><ul><li>A’ = A + c max(0,t in ) </li></ul></ul></ul><ul><ul><ul><li>C’ = A + c min(t out ,1) </li></ul></ul></ul><ul><ul><ul><li>To find t in , t out , consider each bounding line of P and calculate intersection with A+ c t. </li></ul></ul></ul><ul><ul><ul><ul><li>Note: Bounding lines stored in point normal form </li></ul></ul></ul></ul><ul><ul><ul><ul><li>Note: n is outward-pointing normal. </li></ul></ul></ul></ul>
  23. 23. The Clipping problem <ul><li>Init candidate interval to [0,1] </li></ul><ul><li>For each bounding line, find hit time and establish whether entering or exiting ray using n . c . </li></ul><ul><ul><li>If entering, set t in = max (t in , t hit ). </li></ul></ul><ul><ul><li>If exiting, set t out = min(t out ,t hit ). </li></ul></ul><ul><li>Segment from A+ c t in to A+ c t out lies inside P. </li></ul>
  24. 24. Cyrus-Beck clipping:
  25. 25. Cyrus-Beck clipping:

×