Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Computer Graphics Chapter 5 Vector Based Algorithms.

Similar presentations


Presentation on theme: "1 Computer Graphics Chapter 5 Vector Based Algorithms."— Presentation transcript:

1 1 Computer Graphics Chapter 5 Vector Based Algorithms

2 [5]-2RM 2D Coordinate Systems

3 [5]-3RM 3D Coordinate Systems ZX Y X Y Z Right-handed System Left-handed System

4 [5]-4RM 3D Coordinate Systems Right-handed SystemLeft-handed System

5 [5]-5RM Points and Vectors X Y A point denotes a position in space. A vector is a directed line segment, having both magnitude and direction. (x,y) X Y v = (x,y)

6 [5]-6RM Addition and Subtraction of Vectors Two vectors v 1, v 2 can be added to produce the diagonal vector v 1 +v 2 according to the parallelogram rule. The result of vector subtraction produces v 1  v 2 which is a vector directed from v 2 to v 1.

7 [5]-7RM Linear Combination of Vectors A linear combination of vectors v 1, v 2 is given by v = a v 1 + b v 2, where a,b are constants. A linear combination of vectors v 1, v 2 always lies in the plane containing the vectors v 1, v 2. Z X Y v1v1 v2v2 v = a v 1 + b v 2

8 [5]-8RM Affine Combination of Vectors An affine combination of vectors v 1, v 2 is given by v = a v 1 + b v 2, where a,b are constants, and a+b = 1. In particular, v = (1  t) v 1 + t v 2 is an affine combination of vectors. Z X Y v1v1 v2v2 v = (1-t)v 1 + t v 2

9 [5]-9RM Linear Interpolation of Vectors The affine combination v = (1  t) v 1 + t v 2 performs a linear interpolation between vectors v 1 and v 2, if 0  t  1. Z X Y v1v1 v2v2 v = (1-t)v 1 + t v 2

10 [5]-10RM Linear Interpolation of Vectors Example: A color (r,g,b) can be treated as a vector. If C 1 = (r 1, g 1, b 1 ) and C 2 = (r 2, g 2, b 2 ) are two colors then, a linear interpolation between the two colors is given by C = (1  t) C 1 + t C 2, 0  t  1. C1C1 C2C2 C = (1  t) C 1 + t C 2

11 [5]-11RM 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.

12 [5]-12RM Vector Dot Product The dot-product of two vectors v 1 =(x 1, y 1, z 1 ) and v 2 =(x 2, y 2, z 2 ) is v 1.v 2 = x 1 x 2 + y 1 y 2 + z 1 z 2. The cosine of the angle  between two vectors v 1, v 2 is computed as follows: cos  = ( v 1.v 2 ) / (|v 1 | |v 2 |). In particular, when the vectors are orthogonal (  = 90 deg), then v 1.v 2 = 0

13 [5]-13RM Vector Cross Product The cross-product of two vectors v 1 =(x 1, y 1, z 1 ) and v 2 =(x 2, y 2, z 2 ) is v 1 x v 2 = Also, v 1 x v 2 =

14 [5]-14RM Vector Cross Product The vector v 1  v 2 is orthogonal to both the vectors v 1, and v 2. The three vectors v 1, v 2, v 1  v 2 form a right-handed system. (Note that v 1 and v 2 are not necessarily orthogonal. Hence the right-handed system is not mutually orthogonal.)

15 [5]-15RM Planes Any three non-collinear points P 1, P 2, P 3 will define a unique plane. Consider the vectors v 1 = P 2  P 1, and v 2 = P 3  P 1. Both these vectors lie on the plane, and hence the vector n = v 1  v 2 is normal to the plane.


Download ppt "1 Computer Graphics Chapter 5 Vector Based Algorithms."

Similar presentations


Ads by Google