26
Vector Calculus Mengxia Zhu Fall 2007

03 vector calculus

Embed Size (px)

Citation preview

Page 1: 03 vector calculus

Vector Calculus

Mengxia Zhu

Fall 2007

Page 2: 03 vector calculus

Objective

Review vector arithmetic Distinguish points and vectors Relate geometric concepts to their

algebraic representation Describe point, line, and planes Exploit the dot product and cross product

and their applications in Graphics

Page 3: 03 vector calculus

Basic Entities Coordinate system: has an origin and some mutually

perpendicular axes emanating from the origin.

Point P: a location in space

Vector v : with length and direction, physical entities, such as force, and velocity. Vector has no fixed location, seen as points displacement

x

y

z

z

x

y

Left-hand systemRight-hand system

P

Q

V

V=Q-P{2, 3, 9}

Page 4: 03 vector calculus

Vector-scalar multiplication

Multiplication gives a vector Has the same direction as that of

vv

v 2.5v

-v

Vector permits two fundamental operations: add them, multiply them with real number

Page 5: 03 vector calculus

Vector addition Sum of two vectors Subtraction of two vectors Adding and subtraction of

corresponding components of two vectors gives a new vector

v1

v1+v2

v2

v1

v2

v1-v2

v1

v1+v2

v2

v1

v2

v1-v2

Page 6: 03 vector calculus

Linear Combination and Affine Combination A linear combination of vectors

W = a1v1+a2v2 + a3v3 +…+anvn: all weights are scalars.

A linear combination is affine combination of vectors if the sum of all coefficients add up to unity.

A convex combination poses a further restriction on affine combination. Not only must the coefficients sum to unit, but each must also be non-negative

Page 7: 03 vector calculus

Linear Combination of Vectors

The combination is Convex if the coefficients sum to 1, and are not negative. Partition of unit

1

m

i ii

v a v

v1

v2 v=(1-a)v1 + av2

= V1+a(V2-V1)

v1v2

v3

v=a1v1 + a2v2 +(1-a1-a2)v3

a(V2-V1)

Page 8: 03 vector calculus

Normalize a vector

v is represented by n-tuple ( v1,v2,…vn) Magnitude (length): the distance from the tail to the

head.

Normalization: Scale a vector to have a unity length, unit vector

2 2 21 2 ... nv v v v

~ vv

v

Page 9: 03 vector calculus

Point-vector addition

Subtraction of two points P and Q gives a vector v: v=P-Q

Adding a vector v to point Q gives a point K: K=Q+u

PQ

uK

v

Page 10: 03 vector calculus

Dot product Dot product between vector v and vector u gives a scalar If u and v are orthogonal, the dot product equals zero. (a1,a2) dot (b1,b2) = a1xb1 + a2xb2

The most important application of the dot product is to find the angle between two vectors or between two intersecting lines.

vu

v

u

Page 11: 03 vector calculus

The Angle between Two Vectors Hence, dot product varies as the cosine of

the angle from u to v.

cosu v u v v v v

u

v

vu

0u v

v u 0u v

v u 0u v

Page 12: 03 vector calculus

Cross Product

a = (a1, a2, a3), b=(b1, b2, b3)

a x b = ( a2b3 –a3b2), (a3b1-a1b3), (a1b2 – a2b1)

Page 13: 03 vector calculus

Cross Product Cross product between vector v and u gives a

vector

n is a unit vector perpendicular to both u and v. Follow the right-hand rule

u and v are parallel if

The length of the cross product equals the area of the parallelogram determined by u and v

~

sinv u n v u

0v u v

u

v x u

u x v

Page 14: 03 vector calculus

Operation Calculation

Page 15: 03 vector calculus

Operation Calculation

Page 16: 03 vector calculus

Homogeneous representation Revisit coordinate frame system

Ordinary coordinate system, points and vectors are represented the same. However, they are quite different.

Points have location, no direction and size. Vector has no location, but with direction and size.

Page 17: 03 vector calculus

Homogeneous representation cont Represent both points and

vector using the same set of basic underlying objects,

One of the hallmarks of computer graphics, keep straight the distinction between points and vectors with a compact notation. Easy to program…

We view point’s location as an offset from the origin by a certain amount , , ,a b c

1

21 2 3

3

1

21 2 3

3

, , ,

0

( , , , )

1

v

vv av bv cv a b c

v

p

pP ap bp cp a b c

p

Page 18: 03 vector calculus

Homogeneous representation

.

OpenGL uses 4D homogeneous coordinates for all its vertices.

To go from ordinary to homogenous coordinates, if the object is a point, append a 1, if the object is a vector, append a 0.

Point: (x,y,z,1) Vector: (x,y,z,0)

Page 19: 03 vector calculus

Line

A line is defined by two points. It is infinite in length and extending forever in both directions.

A line segment is defined by two endpoints. A ray is semi-infinite, specified by a starting point

and a direction.

C

B

C

B

CB

Page 20: 03 vector calculus

Parametric Representation Line When t varies, the

point P trace out all of the points on the line defined by C and B.

( )L t C bt

b B C

C

B

t<0

t=0

t=1

t>1

L

Page 21: 03 vector calculus

Parametric Plane

Heavy use of polygons in 3D graphics, planes seem to appear everywhere. Three point formParametric representationPoint normal form

Page 22: 03 vector calculus

Parametric form

Equation

Given any values of s and t, we can identify the corresponding point on the plane.

P(s,t) = C + as + bt

C

b

aa = A-C, b = B-C

B

A

Page 23: 03 vector calculus

Three point form of Plane

Given three points A, B, and C. We rewrite the parametric form:

Affine combination of points:

P(s,t) = C + s (A-C) + t(B-C)

P(s,t) = sA+tB+(1-s-t)C

Page 24: 03 vector calculus

Point Normal form

Plane can be specified by a single point B, that lies within it and direction n, normal to the plane.

Normal n is perpendicular to any line lying in the plane.

R is any point on the plane, it satisfies:

B

n

( ) 0n R B

Page 25: 03 vector calculus

Tweening for Art and Animation

The affine combination of points P = A(1-t) + Bt, performs a linear

interpolation between the points A and B. Interesting animation can be created that

show one figure being “tweened” into another. The procedure if simplest if the two figures are polylines based on the same number of points.

Page 26: 03 vector calculus

Tweening

void drawTween ( Point A[], Point B[], int n, float t){

for (int i= 0; i< n; i++){

Point p; P = Tween(A[i], B[i], t);

if ( i == 0 ) moveTo (Px, Py);else lineTo (Px, Py);

}}