Download presentation
Presentation is loading. Please wait.
Published byMatilda Sims Modified over 9 years ago
1
Chapter 4 Vector Tools for Graphics
2
Vectors – The Basics Lecture 11 Fri, Sep 19, 2003
3
Review of Vectors A point specifies a position. A vector specifies a direction and a magnitude. Generally, our vectors will be normalized to have a length of 1.
4
Operations on Points The difference between two points is a vector. v = P – Q The sum of two points is undefined. The product of a scalar and a point is undefined. We should avoid these operations in our programs.
5
Operations on Vectors The sum of two vectors is the vector that is defined by the parallogram rule. u v u + v
6
Operations on Vectors The difference between two vectors is a vector. u u – v v
7
Operations on Vectors The product of a vector and a scalar is a vector. v 4v4v
8
Operations on Points and Vectors The sum or difference of a point and a vector is a point. P v P + v Q – v v Q
9
Points vs. Vectors Points and vectors are not the same. OpenGL treats them differently. However, there is a certain equivalence: PP – O = v
10
Linear Combinations of Vectors A linear combination of vectors v 1, …, v n, is an expression a 1 v 1 + … + a n v n, where a 1, …, a n are real numbers. The linear combination is affine if a 1 + … + a n = 1.
11
Affine Linear Combinations For any set of vectors v 1, …, v n, the set of all affine linear combinations of v 1, …, v n defines a convex polygon. v1v1 v2v2 v3v3 v4v4
12
The Magnitude of a Vector The magnitude of a vector v = (a 1, …, a n ) is |v| = (a 1 2 + … + a n 2 ) 1/2 A vector of length 1 is a unit vector. A vector may be normalized by dividing it by its length: v/|v|.
13
The Vector Class We will use the Vector3 class whenever it is convenient. vector3.h vector3.cpp However, we must be aware that OpenGL knows nothing of our Vector3 class. To OpenGL, a “vector” is a 3- or 4- dimensional array of floats or doubles.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.