1VectorsMike [email protected] State Universitymjb – September 5, 2014Oregon State UniversityComputer GraphicsVectors have Direction and Magnitudemjb – September 5, 2014Oregon State UniversityComputer Graphics222xyzV VVVMagnitude:2A Vector Can Also Be Defined as the Positional Difference Between Two Points( Qx, Qy, Qz )( Px, Py, Pz )mjb – September 5, 2014Oregon State UniversityComputer Graphics(,,)( , , )xyz x xy yz zVVV Q PQ PQ P Unit Vectors have a Magnitude = 1.0mjb – September 5, 2014Oregon State UniversityComputer Graphics222xyzV VVVˆVVVThe circumflex (^) tells us this is a unit vector3Dot Product(,,)xyzAAAA(,,)xyzBBBBmjb – September 5, 2014Oregon State UniversityComputer Graphics()cosxx yy zzABABABAB AB- Because it produces a scalar result (i.e., a single number),this is also called the Scalar ProductA Physical Interpretation of the Dot ProductAˆBThis is important –memorize this phrase!mjb – September 5, 2014Oregon State UniversityComputer GraphicsˆcosAB A-= How much of A lives in the B direction^4A Physical Interpretation of the Dot ProductFThe amount of the force accelerating the car along the road ismjb – September 5, 2014Oregon State UniversityComputer GraphicscosroadFFgg“how much of F is in the horizontal direction?”This is easy to see in 2D, but a 3D version of the same problem is trickier.A Physical Interpretation of the Dot ProductFRmjb – September 5, 2014Oregon State UniversityComputer GraphicsˆcosroadFFFR-The amount of the force accelerating the car along the road is“how much of F is in the R direction?”5A Physical Interpretation of the Dot ProductFRmjb – September 5, 2014Oregon State UniversityComputer GraphicsˆcosroadFFFR-Dot Products are CommutativeABBA--Dot Products are Distributive()()()ABC AB AC- --mjb – September 5, 2014Oregon State UniversityComputer Graphics()()()ABC AB AC- --6The Perpendicular to a 2D VectorV(x,y)IfV(y,x)thenYou can tell that this is true becauseV V (x,y) ( y,x) xy xy 0 cos90-- mjb – September 5, 2014Oregon State UniversityComputer GraphicsCross Product(,,)xyzAAAA(,,)yz zy zx xz xy yxABABABABABABAB (,,)xyzBBBBmjb – September 5, 2014Oregon State UniversityComputer GraphicssinAB ABBecause it produces a vector result (i.e., three numbers),this is also called the Vector Product7A Physical Interpretation of the Cross ProductˆsinAB AAˆBThis is important –memorize this phrase!mjb – September 5, 2014Oregon State UniversityComputer Graphics= How much of A lives perpendicular to the B direction^The Perpendicular Property of the Cross ProductABThe vector is both perpendicular to A and perpendicular to BCurl 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.AAxB.The Right-Hand-Rule Property of the Cross Productmjb – September 5, 2014Oregon State UniversityComputer GraphicsAB8Cross Products are Not CommutativeABBA AxB. BxA.ABABmjb – September 5, 2014Oregon State UniversityComputer GraphicsCross Products are Distributive()()()ABC AB AC A Use for the Cross Product :Finding a Vector Perpendicular to a Plane (= the Surface Normal)Sn()()nRQSQmjb – September 5, 2014Oregon State UniversityComputer GraphicsQR9A Use for the Cross Product :Finding a Vector Perpendicular to a Plane (= the Surface Normal) –This is used in CG Lightingmjb – September 5, 2014Oregon State UniversityComputer GraphicsA Use for the Cross and Dot Products :Is a Point Inside a Triangle? – 3D (X-Y-Z) VersionS()()RQ SQnLet:QP()()nRQ SQ()()qnRQPQ()()rnSRPRmjb – September 5, 2014Oregon State UniversityComputer GraphicsR()()snQSPS(),(),()qr snn nn andnn-- -Ifare all positive, then P is inside the triangle QRS10Is a Point Inside a Triangle?This can be simplified if you are in 2D (X-Y)Sn(,)xxyyRSSRSR()()RSEPR RS-where:QP()(,)xxyyyyxxRSRSSR ()()EPSSQ-Similarly,and:mjb – September 5, 2014Oregon State UniversityComputer GraphicsR,,RSSQQREEEIfare all positive, then P is inside the triangle QRS()()()()SQQREPSSQEPQ QR--A Use for the Cross Product :Finding the Area of a 3D TriangleS12Area Base HeightQheight2gBase QRsinHeight QSmjb – September 5, 2014Oregon State UniversityComputer Graphics11sin ( ) ( )22Area QR QS R Q S Q QR11Derivation of the Law of CosinesSqrQRs22QRs22QRs)()(2QRQRs -)]()[()]()[(2QSSRQSSRs -mjb – September 5, 2014Oregon State UniversityComputer Graphics)()(2)])([()])([(2QSSRQSQSSRSRs-Sqrrqs cos2222Derivation of the Law of SinesS)()()(*2 QRQSQRSArea qrQRQrssinBut, the area is the same regardless of which two sides we use to compute it, so:SqrRqsQrs sinsinsin smjb – September 5, 2014Oregon State UniversityComputer GraphicsDividing by (qrs) gives:sSrRqQ sinsinsin12Distance from a Point to a PlanePnˆdIn high school, you defined a plane by:Ax + By + Cz + D = 0It is more useful to define it by a point on If you want the familiar equation of the plane, it is:which expands out to become the more familiar Ax + By + Cz + D = 0xyz xyzx, y,z Q ,Q ,Q (n ,n ,n ) 0-Qthe plane combined with the plane’s normal vectormjb – September 5, 2014Oregon State UniversityComputer GraphicspyThe perpendicular distance from the point P to the plane is based on the plane equation:ˆdPQ n-The dot product is answering the question “How much of (P-Q) 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.ˆnWhere does a line segment intersect an infinite plane?P1nˆIf point P is in the plane, then:xyzxyzxyzP,P,P Q ,Q ,Q (n ,n,n ) 0-P0P01(1 )PtPtPQThe equation of the line segment is:mjb – September 5, 2014Oregon State UniversityComputer GraphicsyyyIf we substitute the parametric expression for P into the plane equation, then the only thing we don’t know in that equation is t. Solve it for t*. Knowing t* will let us compute the (x,y,z) of the
View Full Document