21
Vectors Review Vectors Review Vectors have no position; they are defined by their length and their direction; more precisely, they are defined as the difference between two points u u That said, at times it is often handy to place them at the origin; if we do this then a point, p =(x , y ), can be represented by the vector v from the origin to p, v =(x - 0, y - 0)=(x , y ) CS4085

Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review

Vectors have no position; they are defined by their lengthand their direction; more precisely, they are defined as thedifference between two points

u

u

That said, at times it is often handy to place them at theorigin; if we do this then a point, p = (x , y), can berepresented by the vector v from the origin to p,v = (x − 0, y − 0) = (x , y)

CS4085

Page 2: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review

Vectors have no position; they are defined by their lengthand their direction; more precisely, they are defined as thedifference between two pointsThat said, at times it is often handy to place them at theorigin; if we do this then a point, p = (x , y), can berepresented by the vector v from the origin to p,v = (x − 0, y − 0) = (x , y)

vv

CS4085

Page 3: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Vector Bases

Just as words are made up from the basic unit of language,letters, likewise vectors are composed of basic vectorsWe call this set of basic vectors a basisThe vectors in a basis do not have to be orthogonal butthey usually areThe vectors in a basis do not have to be of unit length butthey usually areWe will encounter several co-ordinate systems during thesemester and each will actually be a vector basis; that is,any point in the co-ordinate system will be representableby some combination of the basis vectors

CS4085

Page 4: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Vector Bases (contd.)

Some maths textbooks use the notation that the vectorsx,y, z are the three unit-length, orthogonal vectors in thebasis; other books use the notation i, j,kSo if a vector, v , is drawn pointing from (2,0) to (0,3)

in one notation it is v = −2x + 3y;in another notation (book) it could be v = −2i + 3j;and it could also be the vector v = (−2,3), where it isimplicit that we start from the origin (0,0)

CS4085

Page 5: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Arithmetic

vector addition is “head to tail”:

u

v

u + v

vector subtraction is “head to head”:scalar multiplication is a “fraction” of a vector and is avector, itself; if u = (u1,u2, . . . ,un)

T then when r is a realno. (a scalar), ru = (ru1, ru2, . . . , run)

T :

CS4085

Page 6: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Arithmetic

vector addition is “head to tail”:vector subtraction is “head to head”:

u

v

u − v

scalar multiplication is a “fraction” of a vector and is avector, itself; if u = (u1,u2, . . . ,un)

T then when r is a realno. (a scalar), ru = (ru1, ru2, . . . , run)

T :

CS4085

Page 7: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Arithmetic

vector addition is “head to tail”:vector subtraction is “head to head”:scalar multiplication is a “fraction” of a vector and is avector, itself; if u = (u1,u2, . . . ,un)

T then when r is a realno. (a scalar), ru = (ru1, ru2, . . . , run)

T :

u23u

CS4085

Page 8: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Handedness of co-ordinate systems

The handedness of a 3D co-ordinate system is crucial forkeeping consistency between the three (mutuallyperpendicular) dimensions: given the positive directions of2 of the axes, the handedness determines which way thepositive third axis points

In an RHCS where the normal ordering is x , y , z if the yaxis points “up” and the x axis points right then the z axiswould point out of the pageOpenGL is a right handed co-ordinate system; Direct3D isa left handed co-ordinate system

CS4085

Page 9: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Handedness of co-ordinate systems

The handedness of a 3D co-ordinate system is crucial forkeeping consistency between the three (mutuallyperpendicular) dimensions: given the positive directions of2 of the axes, the handedness determines which way thepositive third axis points

Curl your right hand around the third axis grasp-ing from positive x to y , and your thumb willpoint in the positive z direction; this assumesthat normal ordering of axes is x , y , z.

Right-Hand Curl (Screw) Rule

In an RHCS where the normal ordering is x , y , z if the yaxis points “up” and the x axis points right then the z axiswould point out of the pageOpenGL is a right handed co-ordinate system; Direct3D isa left handed co-ordinate system

CS4085

Page 10: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Handedness of co-ordinate systems

The handedness of a 3D co-ordinate system is crucial forkeeping consistency between the three (mutuallyperpendicular) dimensions: given the positive directions of2 of the axes, the handedness determines which way thepositive third axis points

When we talk about cross products laterremember that if the third axis is to pointtowards you then the ordering has got tobe anti-clockwise

Important:

In an RHCS where the normal ordering is x , y , z if the yaxis points “up” and the x axis points right then the z axiswould point out of the pageOpenGL is a right handed co-ordinate system; Direct3D isa left handed co-ordinate system

CS4085

Page 11: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Handedness of co-ordinate systems

The handedness of a 3D co-ordinate system is crucial forkeeping consistency between the three (mutuallyperpendicular) dimensions: given the positive directions of2 of the axes, the handedness determines which way thepositive third axis points

In an RHCS where the normal ordering is x , y , z if the yaxis points “up” and the x axis points right then the z axiswould point out of the pageOpenGL is a right handed co-ordinate system; Direct3D isa left handed co-ordinate system

CS4085

Page 12: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Handedness of co-ordinate systems

The handedness of a 3D co-ordinate system is crucial forkeeping consistency between the three (mutuallyperpendicular) dimensions: given the positive directions of2 of the axes, the handedness determines which way thepositive third axis points

In an RHCS where the normal ordering is x , y , z if the yaxis points “up” and the x axis points right then the z axiswould point out of the pageOpenGL is a right handed co-ordinate system; Direct3D isa left handed co-ordinate system

CS4085

Page 13: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

For two vectors u = (u1,u2, . . . ,un)T and

v = (v1, v2, . . . , vn)T the dot product, u · v is defined as

u · v =n∑

i=1

uivi = u1v1 + · · ·+ unvn = v · u

When we describe vectors in terms of ma-trices

u · v = uT v = vT u 6= vuT 6= uvT

Forward note:

The importance of the dot product is that geometrically it isthe orthogonal projection of one vector on to the other,expressed as a multiple of the other vector’s lengthThat is, it gives a measure of how much of one vectorpoints in the other’s directionThe dot product returns a number, or scalar

CS4085

Page 14: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

For two vectors u = (u1,u2, . . . ,un)T and

v = (v1, v2, . . . , vn)T the dot product, u · v is defined as

u · v =n∑

i=1

uivi = u1v1 + · · ·+ unvn = v · u

The importance of the dot product is that geometrically it isthe orthogonal projection of one vector on to the other,expressed as a multiple of the other vector’s lengthThat is, it gives a measure of how much of one vectorpoints in the other’s directionThe dot product returns a number, or scalar

CS4085

Page 15: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

For two vectors u = (u1,u2, . . . ,un)T and

v = (v1, v2, . . . , vn)T the dot product, u · v is defined as

u · v =n∑

i=1

uivi = u1v1 + · · ·+ unvn = v · u

The importance of the dot product is that geometrically it isthe orthogonal projection of one vector on to the other,expressed as a multiple of the other vector’s lengthThat is, it gives a measure of how much of one vectorpoints in the other’s directionThe dot product returns a number, or scalar

CS4085

Page 16: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

For two vectors u = (u1,u2, . . . ,un)T and

v = (v1, v2, . . . , vn)T the dot product, u · v is defined as

u · v =n∑

i=1

uivi = u1v1 + · · ·+ unvn = v · u

The importance of the dot product is that geometrically it isthe orthogonal projection of one vector on to the other,expressed as a multiple of the other vector’s lengthThat is, it gives a measure of how much of one vectorpoints in the other’s directionThe dot product returns a number, or scalar

CS4085

Page 17: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

Two vectors u and v , graphically

θ

uv

L

L = |u| cos θ , u · v = L|v | = |u||v | cos θ... which is also

CS4085

Page 18: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

Two vectors u and v , graphically... which is also

θ

uv

L′

L′ = |v | cos θ , u · v = L′|u| = |u||v | cos θNote, L′ 6= L

CS4085

Page 19: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

Two more vectors u and v , graphically, u · v is

θuv

L

L = |u| cos θ and u · v = L|v | = |u||v | cos θSince θ > 90◦, cos θ < 0 and then u · v < 0

CS4085

Page 20: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

Dot Product of two Vectors, u · v

Two important properties of dot productif u and v are orthogonal then u · v = 0 (cos θ = 0)if u is of length 1 then u · u = 1 (cos θ = 1)

The connection between the geometric interpretation of the dotproduct and the algebraic formula can be found here

CS4085

Page 21: Quick and Dirty Intro. to Vectors - University of Limerickgarryowen.csisdmz.ul.ie/~cs4815/resources/oth2.pdf · 2009-11-27 · The vectors in a basis do not have to be of unit length

Vectors Review

Vectors Review (contd.)

The Normal

In 2-D (3-d, respectively) the normal is a vector that isperpendicular to a given line (resp. plane)In graphics when we represent objects (cars, animals, etc.)by “wire meshes” of smaller polygons the normal will play acrucial role because it will allow us determine if our camerais pointing towards a polygon or if the polygon faces theother way (the polygon visibility problem)

CS4085