160 likes | 177 Views
Explore 2D and 3D coordinate systems, points, vectors, linear interpolation, dot product, cross product in computer graphics. Learn about affine and linear combinations of vectors.
E N D
Computer Graphics Chapter 5 Vector Based Algorithms
3D Coordinate Systems Y Y Z X Z X Right-handed System Left-handed System
3D Coordinate Systems Right-handed System Left-handed System
Points and Vectors Y Y v = (x,y) (x,y) (x,y) X X A point denotes a position in space. A vector is a directed line segment, having both magnitude and direction.
Addition and Subtraction of Vectors Two vectors v1, v2 can be added to produce the diagonal vector v1+v2 according to the parallelogram rule. The result of vector subtraction produces v1v2 which is a vector directed from v2 to v1 .
Linear Combination of Vectors Y X Z • A linear combination of vectors v1, v2 is given by • v = a v1+ b v2, • where a,b are constants. • A linear combination of vectors v1, v2 always lies • in the plane containing the vectors v1, v2. v1 v2 v = a v1+ b v2
Affine Combination of Vectors Y X Z • An affine combination of vectors v1, v2 is given by • v = a v1+ b v2, • where a,b are constants, and a+b = 1. • In particular, v = (1t) v1+ t v2 is an affine • combination of vectors. v = (1-t)v1+ t v2 v1 v2
Linear Interpolation of Vectors Y X Z The affine combination v = (1t) v1+ t v2 performs a linear interpolation between vectors v1 and v2 , if 0 t 1. v = (1-t)v1+ t v2 v1 v2
Linear Interpolation of Vectors Example: A color (r,g,b) can be treated as a vector. If C1 = (r1, g1, b1) and C2 = (r2, g2, b2) are two colors then, a linear interpolation between the two colors is given by C = (1t) C1+ t C2 , 0 t 1. C1 C = (1t) C1+ t C2 C2
Unit Vector • The magnitude of a vector v is denoted by |v|. • If v=(x,y,z), then |v|= • v/|v| is a unit vector.
Vector Dot Product • The dot-product of two vectors v1 =(x1, y1, z1) and v2 =(x2, y2, z2) is v1.v2= x1x2 + y1y2 + z1z2. • The cosine of the angle between two vectors v1, v2 is computed as follows: cos = (v1.v2) / (|v1| |v2|). • In particular, when the vectors are orthogonal ( = 90 deg), then v1.v2 = 0
Vector Cross Product • The cross-product of two vectors v1 =(x1, y1, z1) and v2 =(x2, y2, z2) is v1 x v2 = Also, v1 x v2 =
Vector Cross Product The vector v1 v2 is orthogonal to both the vectors v1, and v2 . The three vectors v1, v2, v1 v2form a right-handed system. (Note that v1 and v2 are not necessarily orthogonal. Hence the right-handed system is not mutually orthogonal.)
Planes • Any three non-collinear points P1, P2, P3 will define a unique plane. • Consider the vectors v1 = P2P1 , and v2 = P3P1. Both these vectors lie on the plane, and hence the vector n = v1 v2is normal to the plane.