Processing math: 100%

Lecture 5: Vectors

Basics

A 2D point:

p=[xy]

represents a location w/ respect to some coordinate system.

A 2D vector:

v=[xy]

represents a displacement from a position.

Vectors have length and direction - but no inherent location. Can represent a displacement or motion.

Consider that one step north while standing in NYC is the same as one step north while standing in SLO - in terms of displacement/motion.

Notation

We write vectors as lists of components: x0,x1

We write vectors as a column matrix:

v=[x0x1] w=[x0x1x2]

Operations

Scalar

Multiplication by a scalar:

a=[25] b=[32] 4a=[820]

Multiplying a vector by a scalar changes its length, but not its direction.

Addition

a+b=[2+352]=[53]

(this is component-wise)

Vector additional can be visualized by placing the vectors head-to-tail.

Subtraction

Geometric of v is a vector in the opposite direction.

So, subtraction is not suprising:

ab=[a0b0a1b1]

Basis Vectors

Linear Combination

A linear combination of m vectors v1,v2,...,vm is a vector of the form:

w=a1v1+a2v2+...+amvm

where a1,a2,...,am are scalars.

Barycentric coordinates are an example of a linear combination (of 3 vectors).

Linearly Independant

If two vectors are non-zero and not parallel, they are called linearly independant.

For two given linearly independant vectors v1 and v2, we can write any vector v3 in terms of the other two.

v3=2v2+12v1

The two vectors v1 and v2 are then called basis vectors.

Any vector can be expressed as a linear combination of the basis vectors:

c=aca+bcb

Note that the cooeficients ac and bc are unique - that is, a different ac and bc will give a different vector c.

Cartesian Coordinates

If two vectors are at right angles to each other (e.g. they are orthogonal), they form an orthogonal basis.

If the vectors are also both of length 1, we call this an orthonormal basis.

In 2D, we can use 2 such special vectors x and y to define the Cartesian basis vectors:

x=[10] y=[01]

Not surprisingly, the Cartesian basis vectors in 3D are:

x=[100] y=[010] z=[001]

(Note that for a 3D coordinate system, we need three basis vectors.)

Handedness

Depending on where the z axis points, we call a basis left or right handed. This will come up again when we talk about other operations on vectors.

The handedness refers to how the third basis is related to the first two. If the first basis vector is along your thumb and the second basis vector is along your index finger, your palm is pointing in the direction of the third basis vector. Note that this is a different direction for your left or right hand.

In OpenGL, we use a right-handed basis.

Coordinate Frame

A Coordinate Frame (or coordinate system) consists of an origin point o 0,0,0 and a basis of linearly independant vectors a,b,c.

The standard coordinate system in 3D is:

x=[100] y=[010] z=[001] o=0,0,0

Any 3D point q,r,s can be written as:

[qrs]=o+qx+ry+sz