§ The dot product or inner product measures to what degree two vectors are aligned u · v = (u1 ,u2 ) · (v1 ,v2 ) = u1 * v1 + u2 * v2 v * u = (5*7) + (5*3) = 50 v * w = (5*5) + (5*0) = 25 u * w = (7*5) + (3*0) = 35 u * u = (7*7) + (3*3) = 58 t * w = (0*5) + (5*0) = 0 Dot Product q v=[5,5] u=[7,3] w=[5,0] t=[0,5]
§ Two vectors v and w are perpendicular or normal iff u · v = 0 § Geometric Interpretation: § cos(a) = l / ||w|| = u · v / ||v|| * ||w|| Dot Product w v a l
• Notation: u = v x w • The cross product is a vector • ||u|| proportional to the sine of the angle between v and w ||u|| = ||v||*||w||*sin(a) • u is perpendicular to v and w • The direction of u follows the right hand rule Cross Product w v a u
Cross Product | Triangle Area § The cross product is related to the area of a triangle § (parallelogram)area = ||u|| = ||v x w|| = ||v||*||w||*sin(a) § (triangle)area = ||u|| / 2 = ||v x w|| / 2 = ... Q R P w v
Test Yourself § area (triangle) = (0,3,0) x (3,3,0) = ||(0,0,-9)|| / 2 = 9/2 = 4.5 § area (parallelogram) = 9 § area (parallelogram) = (3)(4.24) sin (45) = (3)(4.24...)(0.70...) = 9 Q R P
Cross Product | Distance point to line // compute the distance from AB to C double lineToPointDistance2D (double[] pA, double[] pB, double[] pC) { double dist = cross(pA-pB, pA-pC) / (pA - pB); return Math.abs(dist); } pA pC pB