

































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


































Computer Graphics
Another important mathematical
concept used in graphics is the Vector
If P 1 = (x 1 , y 1 , z 1 ) is
the starting point and P 2 = (x 2 , y 2 , z 2 ) is the ending point, then the vector V = (x 2 – x 1 , y 2 – y 1 , z 2 – z 1 )
This just defines length and
direction , but not position
The magnitude (length) of a vector:
|V| = sqrt( Vx^2 + Vy^2 )
The direction of a vector:
a = tan-1^ (Vy / Vx)
a is angular displacement from the x-axis
3D magnitude is a simple extension of 2D |V| = sqrt( Vx^2 + Vy^2 + Vz^2 )
3D direction is a bit harder than in 2D
“Normalizing” a vector means shrinking or stretching it so its magnitude is 1
Normalize by dividing by its magnitude; V = (1, 2, 3) |V| = sqrt( 1^2 + 2^2 + 3^2 ) = sqrt(14) = 3.74 Docsity.com
Vnorm = V / |V| = (1, 2, 3) / 3. = (1 / 3.74, 2 / 3.74, 3 / 3.74) = (.27, .53, .80) |Vnorm| = sqrt( .27^2 + .53^2 + .80^2 ) = sqrt( .9 ) =. Note that the last calculation doesn’t come out to exactly 1. This is because of the error introduced by using only 2 decimal places in the calculations above.
Equation:
V 3 = V 1 - V 2 = (V1x-V2x, V1y-V2y, V1z-V2z)
Visually:
The dot product of 2 vectors is a scalar
V 1.^ V 2 = (V1x V2x) + (V1y V2y ) + (V1z V2z )
Or, perhaps more importantly for graphics: V 1.^ V 2 = |V 1 | |V 2 | cos(q) where q is the angle between the 2 vectors and q is in the range 0 q
The Dot Product computation can be simplified when it is known that the vectors are unit vectors V 1.^ V 2 = cos(q) because |V 1 | and |V 2 | are both 1
The cross product of 2 vectors is a vector V 1 x^ V 2 = ( V1y V2z - V1z V2y , V1z V2x - V1x V2z , V1x V2y - V1y V2x )
The direction of u is determined by the right hand rule
Note that you can’t take the cross product of 2 vectors that are parallel to each other
Cross products are great for forming coordinate system frames (3 vectors that are perpendicular to each other) from 2 random vectors