Top Banner
Vector Tools for Computer Graphics Computer Graphics
35

Vector Tools for Computer Graphics Computer Graphics.

Jan 14, 2016

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Vector Tools for Computer Graphics Computer Graphics.

Vector Tools forComputer Graphics

Computer Graphics

Page 2: Vector Tools for Computer Graphics Computer Graphics.

Vector Tools for Computer Graphics

Two branches of Mathematics Vector Analysis Transformation

Why Vectors?

Page 3: Vector Tools for Computer Graphics Computer Graphics.

Basic Definitions

Points specify location in space (or in the plane). Vectors have magnitude and direction (like

velocity).

Points Vectors

Page 4: Vector Tools for Computer Graphics Computer Graphics.

Basics of Vectors

v

v

Q

PVector as displacement:

v is a vector from point P to point Q.

The difference between two points is a vector: v = Q - P

Another way:

The sum of a point and a vector is a point : P + v = Q

v

Q

P

Page 5: Vector Tools for Computer Graphics Computer Graphics.

Operations on Vectors

Two operations

Addition

a + b

a = (3,5,8), b = (-1,2,-4)

a + b = (2,7,4)

Multiplication be scalars

sa

a = (3,-5,8), s = 5

5a = (15,-25,40)

operations are done componentwise

Page 6: Vector Tools for Computer Graphics Computer Graphics.

Operations on vectors

Addition

a

b

a+ b

ab

a+ b

Multiplication by scalar

a2a

-a

Page 7: Vector Tools for Computer Graphics Computer Graphics.

Operations on vectors

Subtraction

a

c

a

-c

a-ca

c

a-c

Page 8: Vector Tools for Computer Graphics Computer Graphics.

Linear Combination of Vectors

Linear combination of m vectors v1, v2, …, vm:

w = a1v1 + a2 v2 + …+ amvm

where a1,a2,…am are scalars.

Definition

Types

Affine Combination

a1 + a2 + …+ am = 1

Examples:

3a + 2b - 4c

(1- t)a + (t)b

Convex Combination

a1 + a2 + …+ am = 1

and ai ≥ 0, for i = 1,…m.

Example: .3a + .2b + .5c

Page 9: Vector Tools for Computer Graphics Computer Graphics.

Convex Combination of Vectors

v1

v2

v

a(v2-v1)

v1v2

v3

Page 10: Vector Tools for Computer Graphics Computer Graphics.

Properties of vectors

Length or size

222

21 ... nwww |w|

w = (w1,w2,…,wn)

Unit vector

aa

a

• The process is called normalizing

• Used to refer direction

The standard unit vectors: i = (1,0,0), j = (0,1,0) and k = (0,0,1)

Page 11: Vector Tools for Computer Graphics Computer Graphics.

Dot Product

The dot product d of two vectors v = (v1,v2,…,vn) and w = (w1,w2,…wn):

Properties

1. Symmetry: a·b = b·a

2. Linearity: (a+c) ·b = a·b + c·b

3. Homogeneity: (sa) ·b = s(a·b)

4. |b|2 = b·b

Page 12: Vector Tools for Computer Graphics Computer Graphics.

Application of Dot Product

Angle between two vectors:

c

b

y

xΦb

Φc

θ^^

)cos( cb

Two vectors b and c are perpendicular (orthogonal/normal) ifb·c = 0

Page 13: Vector Tools for Computer Graphics Computer Graphics.

2D “perp” Vector

Which vector is perpendicular to the 2D vector a = (ax,ay)?

Let a = (ax,ay). Then

a┴ = (-ay,ax)is the

counterclockwise perpendicular to a.

a┴

-a┴a

a

What about 3D case?

Page 14: Vector Tools for Computer Graphics Computer Graphics.

Applications: Orthogonal Projection

A

C

v

cL

A

C

v

c

v┴

Mv┴

Kv

Page 15: Vector Tools for Computer Graphics Computer Graphics.

Applications: Reflections

a

n

r

m -m

e e

a

n

r

θ1 θ2

r = a - 2 ( a . n) n

Page 16: Vector Tools for Computer Graphics Computer Graphics.

Cross Product

Also called vector product. Defined for 3D vectors only.

zyx

zyx

bbb

aaa

kji

ba

Properties

1. Antisymmetry: a Χ b = - b Χ a

2. Linearity: (a +c) Χ b = a Χ b + c Χ b

3. Homogeneity: (sa) Χ b = s(a Χ b)

Page 17: Vector Tools for Computer Graphics Computer Graphics.

Geometric Interpretation of Cross Product

axb

a

b

x

y

z

P2

P1P3

1. aXb is perpendicular to both a and b 2. | aXb | = area of the parallelogram defined by a and b

Page 18: Vector Tools for Computer Graphics Computer Graphics.

Representation of Vectors and Points

Page 19: Vector Tools for Computer Graphics Computer Graphics.

Coordinate Frame

P

v

c

a

b

O

Page 20: Vector Tools for Computer Graphics Computer Graphics.

Homogeneous Representation

Basic objects: a,b,c,O Represent points and vectors using these objects

Page 21: Vector Tools for Computer Graphics Computer Graphics.

Homogeneous Representation

To go from ordinary to homogeneous

1.If point append 1 as the last coordinate.2.If vector append 0 as the last coordinate.

To go from homogeneous to ordinary

1.The last coordinate must be made 1 and then delete it2.The last coordinate must be made 0 and then delete it

Page 22: Vector Tools for Computer Graphics Computer Graphics.

Linear Combinations of vectors

The difference of two points is a vector

The sum of a point and vector is a point

The sum of two vectors is a vector

The scaling of a vector is a vector

Any linear combination of vectors is a vector

Page 23: Vector Tools for Computer Graphics Computer Graphics.

Affine Combinations of Points

Two points P=(P1,P2,P3,1) and R=(R1,R2,R3,1):

E = fP + gR=(fP1+gR1, fP2+gR2, fP3+gR3, f+g)

Since affine combination so f+g=1

So, E is a valid point in homogeneous representation

NOT a valid point, unless f + g = 1

Example: 0.3P+0.7R is a valid point, but P + R is not.

any affine combination of points is a legitimate point

Page 24: Vector Tools for Computer Graphics Computer Graphics.

Linear Combinations of Points

Linear combination of two points P and R:

E = fP + gR

If the system is shifter by U

P’ = P + U

R’ = R + U

E’ should be equal to E+U i.e E’=E+U

E should also be shifted by U

But,

E’ = fP’ + gR’ = fP + gR + (f+g)UNOT, unless f + g = 1

Page 25: Vector Tools for Computer Graphics Computer Graphics.

Affine Combinations of Points [contd]

P2

P1 P1+P2

P1+P2

(P1+P2)/2

Page 26: Vector Tools for Computer Graphics Computer Graphics.

Point + Vector = Affine Comb of Points

Let,

P = A + t v and v = B – A

Therefore,

P = A + t (B – A)

=> P = t B + (1 – t) A.

Linear Interpolation

“Tweening”

See Hill 4.5.4

Page 27: Vector Tools for Computer Graphics Computer Graphics.

Representing Lines

Line Line segment Ray

3 types of representations:1. Two point form

2. Parametric representation

3. Point normal form

Page 28: Vector Tools for Computer Graphics Computer Graphics.

Parametric Representation of a Line

y

x

t = 1

B

Cb

t = 0

t < 0

t > 1

Page 29: Vector Tools for Computer Graphics Computer Graphics.

Point Normal Form of a Line

n

B

R

C

Page 30: Vector Tools for Computer Graphics Computer Graphics.

All in One : Representations of Line

Two PointPoint

Normal

Parametric

B = C - n┴

n = (B – C) ┴

n =

b┴

b =

- n┴B = C + bb

= B – C

{C, B}{C, n}

{C, b}

Page 31: Vector Tools for Computer Graphics Computer Graphics.

Planes in 3D

3 fundamental forms Three-point form Parametric representation Point normal form

Page 32: Vector Tools for Computer Graphics Computer Graphics.

Parametric Representation of Plane

C

a

b

Page 33: Vector Tools for Computer Graphics Computer Graphics.

Point Normal Form of a Plane

B

n

Page 34: Vector Tools for Computer Graphics Computer Graphics.

All in One : Representations of Plane

Three PointPoint

Normal

Parametric

A=(0,0,n.C/ nz) C=(C-0) B=(0,n.C/ ny,0)

n = (A-C)x(B – C)

n =

axbb =

nxa

A = C + a

B = C + ba=

A – C

b = B

– C

{A,C,B}

{C, n}

{C, a, b}

a= (0

,0,1

)xn

Page 35: Vector Tools for Computer Graphics Computer Graphics.

Readings

Hill 4.1 – 4.6