1 Vectors Mike Bailey mjb@cs.oregonstate.edu vectors.pptx
Vectors have Direction and Magnitude 2 Magnitude: V V V V 2 2 2 x y z
A Vector Can Also Be Defined as the Positional Difference Between Two Points 3 ( x, y, z ) ( P x, P y, P z ) ( V, V, V ) ( P, P, P) x y z x x y y z z
Unit Vectors have a Magnitude = 1.0 4 V V V V V Vˆ V 2 2 2 x y z The circumflex (^) tells us this is a unit vector
Dot Product 5 A ( Ax, Ay, Az) B ( Bx, By, Bz) AB( A B A B A B ) A B cos x x y y z z Because it produces a scalar result (i.e., a single number), this is also called the calar Product
A Physical Interpretation of the Dot Product 6 A ˆB This is important memorize this phrase! ABˆ A cos ^ = How much of A lives in the B direction
A Physical Interpretation of the Dot Product 7 F The amount of the force accelerating the car along the road is how much of F is in the horizontal direction? F Fcos road This is easy to see in 2D, but a 3D version of the same problem is trickier.
A Physical Interpretation of the Dot Product 8 F The amount of the force accelerating the car along the road is how much of F is in the direction? F Fcos F ˆ road
A Physical Interpretation of the Dot Product 9 F F Fcos F ˆ road
Dot Products are Commutative 10 A B BA Dot Products are Distributive A( BC) ( AB) ( AC)
The Perpendicular to a 2D Vector 11 If V (x,y) then V ( y,x) You can tell that this is true because VV (x,y) ( y,x) xyxy 0 cos90
Cross Product 12 A ( Ax, Ay, Az) B ( Bx, By, Bz) AB( A B A B, A B A B, A B A B ) y z z y z x x z x y y x AB A B sin Because it produces a vector result (i.e., three numbers), this is also called the Vector Product
A Physical Interpretation of the Cross Product 13 ABˆ A sin A This is important memorize this phrase! ˆB ^ = How much of A lives perpendicular to the B direction
The Perpendicular Property of the Cross Product 14 The vector A B is both perpendicular to A and perpendicular to B AxB. The ight-hand-ule Property of the Cross Product Curl the fingers of your right hand in the direction that starts at A and heads towards B. Your thumb points in the direction of AxB. A B
Cross Products are Not Commutative 15 A BBA AxB. BxA. A B A B Cross Products are Distributive A( BC) ( AB) ( AC)
A Use for the Cross Product : Finding a Vector Perpendicular to a Plane (= the urface Normal) 16 n n ( ) ( )
A Use for the Cross Product : Finding a Vector Perpendicular to a Plane (= the urface Normal) This is used in CG Lighting 17
A Use for the Cross and Dot Products : Is a Point Inside a Triangle? 3D (X-Y-Z) Version 18 n Let: n ( ) ( ) P n ( ) ( P) q n ( ) ( P) r n ( ) ( P) s If ( nn ),( nn ), and( nn ) q r s are all positive, then P is inside the triangle
n Is a Point Inside a Triangle? This can be simplified if you are in 2D (X-Y) E ( P) ( ) 19 where: (, ) x x y y P and: (, ) y y x x If E, E, E imilarly, E ( P) ( ) E ( P) ( ) are all positive, then P is inside the triangle
A Use for the Cross Product : Finding the Area of a 3D Triangle 20 height Area Base 1 BaseHeight 2 Height sin 1 1 Area sin ( ) ( ) 2 2
21 Derivation of the Law of Cosines q r s s 2 2 s ) ( ) ( 2 s )] ( ) [( )] ( ) [( 2 s ) ( ) 2( )] )( [( )] )( [( 2 s qr r q s cos 2 2 2 2
Derivation of the Law of ines 22 r q 2* Area( ) ( ) ( ) rs sin s But, the area is the same regardless of which two sides we use to compute it, so: rs sin qs sin qr sin Dividing by (qrs) gives: sin q sin r sin s
P d Distance from a Point to a Plane nˆ In high school, you defined a plane by: Ax + By + Cz + D = 0 23 It is more useful to define it by a point on the plane combined with the plane s normal vector If you want the familiar equation of the plane, it is: x,y,z,, (n,n,n ) 0 which expands out to become the more familiar Ax + By + Cz + D = 0 x y z x y z The perpendicular distance from the point P to the plane is based on the plane equation: d P nˆ The dot product is answering the question How much of (P-) is in the direction?. Note that this gives a signed distance. If d > 0., then P is on the same side of the plane as the normal points. This is very useful. ˆn
Where does a line segment intersect an infinite plane? 24 P 1 nˆ P The equation of the line segment is: P (1 tp ) tp 0 1 If point P is in the plane, then: P,P,P,, (n,n,n ) 0 x y z x y z x y z If we substitute the parametric expression for P into the plane equation, then the only thing we don t know in that equation is t. olve it for t*. Knowing t* will let us compute the (x,y,z) of the actual intersection using the line equation. If t* has a zero in the denominator, then that tells us that t*=, and the line must be parallel to the plane. This gives us the point of intersection with the infinite plane. We could now use the method covered a few slides ago to see if P lies inside a particular triangle. P 0
Minimal Distance Between Two 3D Lines 25 v p d v q P 0 0 The equation of the lines are : P P 0 t v p 0 t v q The minimal distance vector between the two lines must be perpendicular to both A vector between them that is perpendicular to both is: v v p v q We need to answer the question How much of ( 0 -P 0 ) is in the direction?. To do this, we once again use the dot product: d P 0 0 vˆ v
Another use for Dot Products : Force One Vector to be Perpendicular to Another Vector 26 Here, we want to force A to become perpendicular to B A A ˆB A But, A The strategy is to get rid of the parallel component, leaving just the perpendicular A A A A A A ( ABˆ) Bˆ o that A A A( ABˆ) Bˆ This is known as Gram-chmidt orthogonalization