Presentation is loading. Please wait.

Presentation is loading. Please wait.

Under the Hood – How the Graphics Pipeline Works

Similar presentations


Presentation on theme: "Under the Hood – How the Graphics Pipeline Works"— Presentation transcript:

1 Under the Hood – How the Graphics Pipeline Works
Part II Under the Hood – How the Graphics Pipeline Works

2 Points and Vectors Lecture 18 Fri, Oct 5, 2007

3 3D Coordinate Space There are three mutually orthogonal axes: the x-axis, the y-axis, and the z-axis. In the standard viewing position, the x- and y-axes look the same as in the usual 2D coordinate system. The positive z-axis points towards the viewer; the negative z-axis points away.

4 3D Coordinate Space y x z

5 3D Coordinate Space y Point x z

6 3D Coordinate Space y Point y x z z x

7 Points and Vectors A point specifies a position in space.
A vector specifies a direction and a magnitude. Often, our vectors will be normalized to have a length of 1. In those cases, we will use vectors for direction only.

8 3D Coordinate Space y Point y x z z x

9 3D Coordinate Space y Point Vector y x z z x

10 Homogeneous Coordinates
Points and vectors are in homogeneous coordinates (x, y, z, w). For points, w  0. For vectors, w = 0. For points, the true 3-dimensional coordinates are (x/w, y/w, z/w). For this reason, we usually want w = 1.

11 Points and Vectors Two points determine a vector. A B

12 Points and Vectors Two points determine a vector. A B v = B – A

13 Points and Vectors The difference between two points A = (a1, a2, a3, 1) and B = (b1, b2, b3, 1) is the vector B – A = (b1 – a1, b2 – a2, b3 – a3, 0). It is not permissible to add points or to multiply points by a scalar. Why not?

14 Vector Addition The sum of two vectors is a vector, as defined by the parallogram rule. u v

15 Vector Addition The sum of two vectors is a vector, as defined by the parallogram rule. u v

16 Vector Addition The sum of two vectors is a vector, as defined by the parallogram rule. u u + v v

17 Vector Addition The sum of the vectors u = (u1, u2, v3, 0) and v = (v1, v2, v3, 0) is the vector u + v = (u1 + v1, u2 + v2, u3 + v3, 0).

18 Vector Subtraction The difference between two vectors is a vector. u v

19 Vector Subtraction The difference between two vectors is a vector.
u – v v

20 Vector Subtraction The difference between the vectors u = (u1, u2, v3, 0) and v = (v1, v2, v3, 0) is the vector u – v = (u1 – v1, u2 – v2, u3 – v3, 0).

21 Scalar Multiplication
The product of a vector and a scalar is a vector. v

22 Scalar Multiplication
The product of a vector and a scalar is a vector. v 4v

23 Scalar Multiplication
The product of a vector and a scalar is a vector. v -v

24 Scalar Multiplication
The product of the vector v = (v1, v2, v3, 0) and the scalar a is the vector av = (av1, av2, av3, 0).

25 Point-Vector Addition
The sum of a point and vector is a point. A v

26 Point-Vector Addition
The sum of a point and vector is a point. A B = A + v v

27 Point-Vector Addition
The sum of the point A = (a1, a2, a3, 1) and the vector v = (v1, v2, v3, 0) is the point A + v = (a1 + v1, a2 + v2, a3 + v3, 1).

28 Point-Vector Subtraction
A point minus a vector is a point. A v

29 Point-Vector Subtraction
The sum of a point and vector is a vector. A v -v B = A – v

30 Point-Vector Subtraction
The difference between the point A = (a1, a2, a3, 1) and the vector v = (v1, v2, v3, 0) is the point A – v = (a1 – v1, a2 – v2, a3 – v3, 1). It is the same as A + (-v).

31 Point-Vector Arithmetic
The following operations should be avoided. Point + point: A + B Scalar * point: aA Vector – point: v – A Suppose we want to find the midpoint of the line segment from A to B. How could we do it?

32 Affine Combinations of Points
An affine combination of points P1, P2, …, Pn, is a linear combination a1P1 + a2P2 + … + anPn, where a1, a2, …, an are real numbers and a1 + a2 + … + an = 1. This is a permissible calculation. What will it produce?

33 Vector Magnitude The magnitude of a vector is given by the distance formula. Let v = (v1, v2, v3). The magnitude of v, denoted |v|, is given by

34 Normalized Vectors To normalize a vector, we divide it by its length.
That is, for any vector v  0, the unit vector n with the same direction as v is

35 The Point3D and Vector3D Classes
point3d.h, point3d.cpp vector3d.h, vector3d.cpp


Download ppt "Under the Hood – How the Graphics Pipeline Works"

Similar presentations


Ads by Google