1mjb – October 2, 2007Oregon State UniversityComputer GraphicsVectorsMike BaileyOregon State Universitymjb – October 2, 2007Oregon State UniversityComputer GraphicsVectors have Direction and Magnitude( Vx, Vy, Vz)222xyzV VVV=++2mjb – October 2, 2007Oregon State UniversityComputer GraphicsA Vector Can Also Be Defined as the Positional Difference Between Two Points( Vx, Vy, Vz)(,,)( , , )xyz x xy yz zVVV Q PQ PQ P=− − −( Qx, Qy, Qz)( Px, Py, Pz)mjb – October 2, 2007Oregon State UniversityComputer GraphicsUnit Vectors have a Magnitude = 1.0( Vx, Vy, Vz)222xyzV VVV=++ˆVVV=3mjb – October 2, 2007Oregon State UniversityComputer GraphicsDot Product()cosxx yy zzAB AB AB AB ABθ•= + + =ABθBecause it produces a scalar result (i.e., a single number), this is also called the Scalar Productmjb – October 2, 2007Oregon State UniversityComputer GraphicsA Physical Interpretation of the Dot ProductˆcosAB Aθ•=AθˆB= How much of A lives in the B direction^4mjb – October 2, 2007Oregon State UniversityComputer GraphicsDot Products are CommutativeABBA•=•Dot Products are Distributive()()()ABC AB AC•+ =•+•mjb – October 2, 2007Oregon State UniversityComputer GraphicsCross Product(,,)yz zy zx xz xy yxABABABABABABAB×= − − −ABθsinAB ABθ×=Because it produces a vector result (i.e., three numbers), this is also called the Vector Product5mjb – October 2, 2007Oregon State UniversityComputer GraphicsA Physical Interpretation of the Cross ProductˆsinAB Aθ×=Aθ}ˆB= How much of A lives perpendicular to the B direction^mjb – October 2, 2007Oregon State UniversityComputer GraphicsThe Perpendicular Property of the Cross ProductAB×The vectoris both perpendicular to A andperpendicular 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.ABAxB.The Right-Hand-Rule Property of the Cross Product6mjb – October 2, 2007Oregon State UniversityComputer GraphicsCross Products are Not CommutativeABBA×=−×Cross Products are Distributive()()()ABC AB AC×+ =×+×mjb – October 2, 2007Oregon State UniversityComputer GraphicsA Use for the Cross Product :Find a Vector Perpendicular to a Plane (=the Surface Normal)QRS()()nRQSQ=−×−n7mjb – October 2, 2007Oregon State UniversityComputer GraphicsA Use for the Cross and Dot Products :Is a Point inside a Triangle?QRSP()()nRQSQ=−×−nLet:()()QnRQPQ=−×−()()RnSRPR=−×−()()snQSPS=−×−(),(),()qr snn nn andnn•• •Ifare all positive, then P is inside the triangle QRSmjb – October 2, 2007Oregon State UniversityComputer GraphicsA Use for the Cross Product :Area of a Triangle11sin ( ) ( )22Area QR QS R Q S Qθ=⋅ ⋅ ⋅ =⋅ − × −QRSheightθ12Area Base Height=⋅ ⋅Base QR=sinHeight QSθ=8mjb – October 2, 2007Oregon State UniversityComputer GraphicsDerivation of the Law of CosinesQRSqrsQRs−=22QRs −=)()(2QRQRs −•−=)]()[()]()[(2QSSRQSSRs −+−•−+−=)()(2)])([()])([(2QSSRQSQSSRSRs −•−−−−+−−=Sqrrqs cos2222−+=mjb – October 2, 2007Oregon State UniversityComputer GraphicsDerivation of the Law of SinesQRSqrs)()()(*2 QRQSQRSArea −×−=ΔQrssin=But, the area is the same regardless of which two sides we use to compute it, so:SqrRqsQrs sinsinsin ==Dividing by (qrs) gives:sSrRqQ sinsinsin==9mjb – October 2, 2007Oregon State UniversityComputer GraphicsDistance from a Point to a PlaneThe equation of the plane is:which expands out to become the more familiar Ax + By + Cz + D = 0The distance from the point P to the plane is based on this:()()()0),,(,,,,000=•−zyxzyxnnnPPPzyx()nPPdˆ0•−=The dot product is answering the question “How much of (P-P0) is in the normal direction?”. Note that this gives a signed distance. If d > 0, then P is on the same side of the plane as the normal.:PnˆP0dmjb – October 2, 2007Oregon State UniversityComputer GraphicsDistance from a 3D Line to a 3D LineThe equation of the lines are :A vector between them that is perpendicular to both is:pvtPP⋅+=0()⊥•−= vQPdˆ00We need to answer the question “How much of (Q0-P0) is in the v direction?”. To do this, we once again use the dot product:vpP0dQ0vqqvtQQ⋅+=0qpvvv×=⊥10mjb – October 2, 2007Oregon State UniversityComputer GraphicsA Use for Dot Products :Force One Vector to be Perpendicular to Another VectorThis is known as Gram-Schmidt orthogonalizationAAA⊥=+&AθA⊥A&ˆBAAA⊥=−&ˆˆ()AAAABB⊥′==−•ˆˆ()AABB=•&But,So thatThe strategy is to get rid of the parallel component, leaving just the
View Full Document