Level 1: Vectors and Matrices

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

When we need to express the Magnitude of a vector *v*, we use...?

2 Vertical bars on either side to make it appear as: ||*v*||

Matrix (Scalar) Multiplication

A matrix M is multiplied by a scalar t by applying the multiplication to *every* entry of the matrix.

Any non-zero Vector can be turned into a Unit Vector by...?

Dividing it by its own magnitude/length. The magnitude/length is a scalar quantity, and when we say that we're dividing a vector by a scalar t, we really mean that we're multiplying by the scalar's reciprocal, 1/t. Thus, a non-zero vector *v* can be turned into a unit vector *v∧* using the formula: *v∧* = *v* / ||*v*|| The "hat" is a common way of indicating that the vector has a magnitude/length of 1.

Magnitude

Greatness of size, strength, or importance. In the case of Vector Mathematics, it is the size of the scalar or Length of the vector.

Skew Symmetric Matrix

If the entries of a transpose *M*^T are equal to the negations of the same entries in the matrix *M*, then the matrix *M* is called an *Antisymmetric Matrix* or a *Skew-Symmetric Matrix*. For this to be possible, all of the entries of the main diagonal must be zero. EX: 0 1 -4 -1 0 7 4 -7 0

Scalar Multiplication produces a Vector with a new magnitude/length, but with a direction that is...?

Parallel to the original vector. Vector points in the same direction when the scalar is positive, and the opposite direction when the scalar is negative. A vector with the exact same magnitude but

(t*A*)*B* = *A*(t*B*) = t (*AB*)

Scalar value can be moved around when doing Matrix Multiplication

A Vector can be used to represent a point that does not have a location in space by...?

Thinking of the vector as a relative offset from a given origin. Basically, if the point has no data about it, we can just say that it is (x, y, z) away from the thing we DO have data about.

Matrix Addition & Matrix Subtraction

Two matrices *of the same size* can be added or subtracted by simply adding or subtracting corresponding entries.

Vector Addition

a+ b = ( a₀ + b₀, a₁ + b₁, ... , aₙ−₁ + bₙ−₁) The effect of adding two vectors a and b can be visualized by drawing the vector a anywhere and then placing the beginning of the vector b at the end of the vector a where its arrowhead is drawn. The vector a + b is then drawn as the arrow beginning where a begins and ending where b ends. Vector addition and scalar-vector multiplication exhibit many of the same basic algebraic properties as ordinary numbers due to the component-wise nature of the operations.

The magnitude/length of an n-dimensional Vector is calculated with the formula...?

||*v*|| = √Σ v²_i with n-1 and i = 0 which is just the Pythagorean theorem in n dimensions. In 3D, we can expand the summation and write: ||*v*|| = √v_x² + v_y² + v_z² where we are now using the labels x, y, and z instead of the numerical subscripts 0, 1, and 2 to designate different components.

If two vectors a and b are parallel, either because they point in the same direction or they point in opposite directions, then the cross product a x b is...?

*ZERO*, no matter what the magnitudes of a and b are. Because they are parallel, one of the vectors can be written as a scalar multiple of the other, so we can say that b = ta for some scalar t.

Examples of Vectors

1. Force 2. Velocity 3. Displacement 4. Acceleration 5. Momentum The difference between 2 points contains information about both the distance between the points (which is the magnitude) and the direction that you would need to go to get from one point to the other along a straight line. The velocity of a projectile at a particular instant is given by both its speed (the magnitude) and the direction in which it is currently traveling. A force acting on an object is represented by both its strength (its magnitude) and the direction in which it is applied.

When two vectors a and b are not parallel, the cross product ax b is...?

A new vector that is Perpendicular to both a and b. This is evident if we calculate the dot products a · (a x b) and b · (a x b) because both of them are always zero.

Vector

A quantity that carries enough information to represent 2 things: 1. A direction in space 2. A magnitude Usually written in bold to differentiate them from scalars.

Four-Dimensional Space (4D)

A setting in which a great deal of mathematics is done in the course of game engine development. The first 3 components of a 4D vector are still called x, y, and z, but we have run out of letters in the alphabet beyond that, so the universally accepted practice is to call the 4th component w. It's also referred to as the "weight" value, so w is appropriate.

unit vector

A vector that has a length/magnitude of 1 is called a Unit Vector. Unit Vectors are particularly important because they are able to provide DIRECTION without a magnitude when a meaningful size of some kind is unnecessary. A vector u for which ‖u‖ = 1 is called a unit vector.

Negated Vector

A vector that has been multiplied by the scalar -1. The direction is reversed, but the magnitude/length is unchanged. Written as -*v*.

Column Vector / Row Vector

An n-dimensional vector can be regarded as an n x 1 matrix or a 1 x n matrix, and as such is called a Column Vector or a Row Vector, respectively. These are the Transpose of each other and can be switched to suit the need. *v* = (v0, V1,···,vn-1) = [ v0 ] [ v1 ] ... [ vn - 1] A comma-separated list of n components is equivalent to an n x 1 matrix containing the same numbers in the same order.

Diagonal Matrix

Any Matrix for which ALL of the non-diagonal entries are 0 is called a Diagonal Matrix. 3 0 0 0 8 0 0 0 4 Note that if some or even all of the Diagonal Entries are all 0, it is STILL a Diagonal Matrix.

Components of a Vector

In *n* dimensions, a direction and a magnitude are described by *n* numerical coordinates. When we want to write down the complete value of a vector, we often list these inside parentheses. For example, a three-dimensional vector v having 1, 2, and 3 is written as: *v* = (1, 2, 3)

Matrix as an array of Column Vectors

It is frequently useful to treat our Matrix as an array of Column Vectors (or Row Vectors). Suppose the *a*, *b*, and *c* are 3D Column Vectors. The we can construct a 3x3 matrix *M* by making those vectors the columns of the matrix and writing it as: *M* = [*a* *b* *c*] When matrices are used to transform from one coordinate system to another in Chapter 2, treating the columns of a matrix as a set of vectors will become particularly meaningful.

Matrix

Mathematical object composed of a set of numerical quantities arranged in a two-dimensional array of rows and columns. When a matrix has n rows and m columns, we say that its size is n x m. If its the case that n = m, then it is called a Square Matrix. The numbers that make up a matrix *M* are called its Entries. 2 x 3 Matrix: *M* = 1 2 3 4 5 6 Matrices are represented in *BOLD* capital letters.

Matrix Multiplication

Matrix multiplication is one of the most frequently used algebraic operations in game engine development. It is primarily applied to the transformation of geometric objects such as directions, points, and planes from one coordinate system to another, which is an important topic. Two matrices can be multiplied together if and only if the number of columns in the first matrix is equal to the number of rows in the second matrix. The result is a new matrix having the same number of rows as the first matrix and the same number of columns as the second matrix. That is, if *A* is an n x p matrix, and *B* is a p x m matrix, then the product *AB* is an n x m matrix. Note that the order of multiplication cannot generally be reversed. The product BA does not exist in this example unless n = m. Matrix multiplication is not generally commutative, so when both products do exist, it' s not true that AB = BA except in special situations. The calculation of the ( i, j) entry of the matrix AB involves only row i of the matrix A and only column j of the matrix B, which both contain p entries that are multiplied together and summed.

Matrix-Vector Multiplication

One of the most common matrix products arising in game engine development is a 3 x 3 matrix *M* multiplied by a 3 x 1 column vector *v*. The result is a new 3 x 1 column vector that has possibly been rotated to a new orientation or scaled in some way. The matrix-vector product *Mv* is a linear combination of the columns of *M*, and the coefficients/multipliers are the components of *v*. If we write *M* = [ *a b c*], then we have: *Mv*=vx*a* + vy*b* + vz*c* This is particularly illuminating if we consider the Unit Vectors parallel to the coordinate axes. Let's pretend the original vector *v* was a Unit Vector along one of the axes. Then: If *v* = (1, O, O), then *Mv* = *a*; If *v* = (O, 1, O), then *Mv* = *b*; If *v* = (O, O, 1), then *Mv* = *c*. Why is this useful? Because the columns of M tell us exactly how the x, y, and z axes are reoriented in a new coordinate system established through multiplication by the matrix M. This is the key concept within the topic of coordinate transformations.

Scalar

Quantity such as distance, mass, or time that can be fully described using a single numerical value representing its size, or its *magnitude*. Usually written in italic to differentiate them from vectors.

Dot Product (AKA Scalar Product)

The Dot Product between two n-dimensional vectors *a* and *b* is a SCALAR quantity given by the formula: *a · b* = *axbx* + *ayby* + *azbz* The corresponding components of the two vectors are multiplied together and summed. This product gets its name from the notation: a · b in which a dot is placed between the two vectors participating in the product. Because the Dot Product produces a Scalar quantity, it is also known as the Scalar Product. *a · b* = *a ^T b* which produces a 1 x 1 matrix having a single entry. The dot product of a vector with itself produces the squared magnitude of that vector. W e use the special notation v² in place of the dot product v · v or the squared magnitude ||v||² for its conciseness. All three expressions have the same meaning. When squared, it is a common convention to write the letter representing a vector in italic because the result of the dot product of a vector with itself is a scalar quantity.

Diagonal Entries (in a matrix)

The entries *M*_ii where the row and column indexes are equal to each other are called the Diagonal Entries of the Matrix *M*.

The *Transpose* of a Matrix

The matrix denoted as *M*^T whose rows are equal to the columns of *M*, or equivalently, whose columns are equal to the rows of *M*. The *Transpose* of a matrix van be thought of as the reflection of its entries across the main diagonal. If a matrix *M* is equal to its Transpose *M*^T, then its called a Symmetric Matrix. Every Diagonal Matrix is automatically Symmetric.

Cross Product (AKA Vector Product)

The multiplication of two vectors which results in a vector. The cross product between two 3D vectors a and bis another 3D vector given by the formula: a x b =(aybz -azby, azbx - axbz, axby - aybx) Each component of the result involves products of the other two components of the vectors being multiplied together. For example, the z component of the cross product is calculated using the x and y components of the input vectors. As with the dot product, the cross product gets its name from the notation ax b in which a cross is placed between the two vectors participating in the product. Because it produces a vector quantity, the cross product is also known as the vector product. It's important to emphasize that the cross product is defined ONLY for three dimensions, whereas the dot product is defined for ALL numbers of dimensions. If the vectors a and b are NOT parallel, then they establish a 2D plane to which the cross product (a x b) is perpendicular, and we have two choices as to what direction the vector (a x b) actually points. If we are looking at the plane from a position not lying in the plane itself, then (a x b) could point toward us, or it could point away from us. The correct direction is determined by the handedness of the coordinate system.

Normalization

The process of setting a vector's magnitude/length to 1. A unit vector that has been produced by this process is referred to as *Normalized*. Note: This is NOT related to the Normal Vector!

(*AB*)^T = *B*^T*A*^T

The transpose of matrix *A* times matrix *B* is the same as the transpose of *B* times transpose of *A* ABT = BTAT

Zero Vector

The vector whose components are all 0, and it is the only vector for which the magnitude is zero. Sometimes represented in bold as *0*. Vector denoted by <0,0> (no magnitude and no direction, but it exists)

Vector Multiplication

There are a number of ways to multiply two vectors together. The most obvious is to apply the multiplication component-wise, and this is what happens in all modern shading languages when the multiplication operator appears in the code. However, this has very little physical significance and is mainly used for multiplying colors together. When vectors are being used to represent quantities with some *GEOMETRIC* meaning, the most constructive methods of multiplication are two operations: 1. Dot Product 2. Cross Product

The Magnitude/Length of a Vector can be changed by multiplying it by a Scalar Value.

Vector *v* Scalar t t*v* = (tv₀, tv₁, ..., tvₙ₋₁) Scalar Multiplication is a Commutative operation, meaning that it doesn't matter on which side we multiply by t because its always the case that t*v* = *v*t. In the formula for the magnitude/length of t*v*, the value t² now appears in each term of the summation, so it can be factored out and removed from the radical as |t|. Thus, multiplying a vector *v* by a scalar t changes the magnitude/length of *v* by a factor of |t|/ This can be written as: ||t*v*|| = |t| ||*v*|| demonstrating that the absolute value of a scalar quantity can always be pulled out of the expression for evaluating a magnitude.

We identify an individual component of a vector *v* by...?

Writing a zero-based subscript such that v₀ means the first component, v₁ means the second component, etc. We use it this way because computers do the same thing when indexing. So an n-dimensional vector *v* is written as: *v* = (v₀, v₁, ..., vₙ₋₁) The outer v is bold as it is the symbol for the vector, while the inner v's are written in italics because the components are scalar quantities. We can also identify the components of a vector *v* by using labels that correspond to the coordinate axes. In 3 dimensions, we often write: *v* = (v_x, v_y, v_z) where x, y, and z should be subscripts.

An individual Entry in a matrix *M* is identified by ...?

Writing two zero-based subscripts such that the first subscript represents the row index, and the second subscript represents the column index. The symbol M_ij means the entry appearing in the i-th row and the j-th column. Sometimes a comma is inserted for clarity. M₀₀ is the first entry in the Matrix. M₀,₁ is the second entry in the first row.

Vector Subtraction

a+ b = ( a₀ - b₀, a₁ - b₁, ... , aₙ−₁ - bₙ−₁) The difference between two vectors a and b can be visualized in much the same way as their sum, except that in the case of a- b, the vector b is negated before its beginning is placed at the end of the vector a. We simply reverse the direction of the vector being subtracted.

The dot product between two vectors a and b satisfies the equality:

a· b = ||*a*|| ||*b*|| cos θ where θ is the planar angle between the directions of a and b if they were to be drawn as arrows starting at the same location. This equality represents the MAIN application of the dot product, and it provides a computationally cheap way to determine how much two vectors are parallel to each other or perpendicular to each other. If a and b are both unit vectors (i.e., they both have a magnitude of one), then a · b is always in the range [ -1, 1] because in this case a · b = cos θ, and the range of the cosine function is [ -1, 1]. If a and b are perpendicular, then a · b is ZERO no matter what the magnitudes of a and b are. In general, the dot product is positive when the angle between the vectors is less than 90 degrees and negative when the angle is greater than 90 degrees, as illustrated in Figure 1.6. Loosely speaking, the dot product provides a measure of how much one vector is like another.


Ensembles d'études connexes