• Tidak ada hasil yang ditemukan

CPCS 391 Computer Graphics 1

N/A
N/A
Protected

Academic year: 2025

Membagikan "CPCS 391 Computer Graphics 1"

Copied!
21
0
0

Teks penuh

(1)

CPCS 391

Computer Graphics 1

Instructor: Dr. Sahar Shabanah Computer Graphics Math Review

(2)

Scalars

• Scalar Field

– Ex) Ordinary real numbers and operations on them

• Two Fundamental Operations

Addition and Multiplication

Commutative

Associative

Distributive

S S

S    

  ,  ,   ,  

a + b = b + a a × b = b × a

a + ( b + g ) = ( a + b ) + g

a × ( b × g ) = ( a × b ) × g

a × ( b + g ) = ( a × b ) + ( a × g )

(3)

Scalars

• Two Special Scalars

– Additive identity: 0,

– multiplicative identity: 1 – Additive inverse and – Multiplicative inverse

a + 0 = 0 + a = a

1

a + - ( ) a = 0

a × 1 = 1 × a = a

a × a

-1

= 1

(4)

Vectors

A vector is a directed line segment:

starts at initial point (A) and ends at terminal point (B)

Components of v

In general:

v = n-tuples

Special Vectors:

Zero Vector

Negative Vector

4

v = AB

 

0

0

u u

u u

v v vn

v1, 2,,

v = (x2 - x1,y2 - y1) =

(

v1,v2

)

A(X1,Y1)

B(X2,Y2)

v

(5)

• Scalar-Vector Multiplication

u and v: vectors, α and β: scalars

Vectors Operations

a (

u + v

)

=

a

u +

a

v

a

+

b

( )

u =

a

u +

b

u

 v v v

n

v   

 

1

,

2

,  ,

(6)

Vectors Operations

• Magnitude (length)

• Vector-Vector Addition

– Head-to-tail axiom:

– u+v=(u tial, v head)

   

 u u u v u u

n

v v u v

n

v

n

v 

n

v u

, ,

,

, ,

, ,

, ,

2 2

1 1

2 1 2

1

v = v

12

+ v

22

+ .. + v

n2
(7)

Vectors Operations

• Vector-Vector Difference

u - v = ( u

1

, u

2

, … , u

n

) - ( v

1

, v

2

,… , v

n

)

= ( u

1

- v

1

, u

2

- v

2

,… , u

n

- v

n

)

V

U

U-V

(8)

Vectors Operations

• dot Product:

combine two vectors to form a real number

measure of the angle between two vectors, to what degree those two vectors are aligned

» cosθ = 1  parallel

» cosθ = 0  orthogonal

n nv u v

u v

u v

u

or v

u v

u

...

.

, cos .

2 2 1

1

v u

v cos u.

(9)

• The cross product of vectors u and v is a vector uxv which is perpendicular to u and v

• The magnitude of uxv is proportional to the cosine of the angle between u and v

• The direction of uxv follows the right hand rule

Vectors: Cross Product

u ´ v = (u

2

v

3

- u

3

v

2

, u

3

v

1

- u

1

v

3

, u

1

v

2

- u

2

v

1

) or

u ´ v = u v sin q

(10)

Affine Space

• In 3D Space, a unit Vector, e3 , is Orthogonal to Given Two Nonparallel Vectors, e1 and e2

• Definition

• Consistent Orientation

– Ex) x-axis x y-axis = z-axis

0 2

3 1

3  e  e  e  e

 

 

1 2 2

1

3 1 1

3

2 3 3

2

2 1

3

e e

e

1

,

2

,

3

 , 2 

1

,

2

,

3

1

where e     e    

(11)

Affine Spaces

 Coordinate System

 Origin: a particular reference point

Arbitrary placement

of basis vectors Basis

vectors located at the origin

(12)

What is a Matrix?

• A matrix is a set of elements, organized into rows and columns

rows

columns

 

 

d c

b

a

(13)

Definitions

dimension of a matrix

– n x m array of scalars (n Rows and m Columns)

square matrix

– m = n  square matrix of dimension n

Element

Transpose:

– interchanging the rows and columns of a matrix

Column and Row Matrices:

Column matrix (n x 1 matrix):

Row matrix (1 x n matrix):

  a

ij

, i  1 ,  , n , j  1 ,  , m

 

aij

A

 

ji

T a

A

 









n i

b b b

b

2 1

b

(14)

Basic Operations

• Addition

• Subtraction

• Multiplication



 

 



 

 



 

h d

g c

f b

e a

h g

f e

d c

b a



 

 



 

 



 

h d

g c

f b

e a

h g

f e

d c

b a



 

 



 



 

dh cf

dg ce

bh af

bg ae

h g

f e

d c

b a

Just add elements

Just subtract elements

Multiply each row by each column

(15)

Matrix Operations

• Scalar-Matrix Multiplication

• Matrix-Matrix Addition

• Matrix-Matrix Multiplication

– A: n x l matrix, – B: l x m 

– C: n x m matrix

   a

ij

 A 

 a

ij

 b

ij

 A B C

 

l

k

kj ik ij

ij

b a c

c

1

AB

C

(16)

Properties of Matrix Operations

Scalar-Matrix Multiplication

Matrix-Matrix Addition Commutative:

Associative:

Identity Matrix I (Square Matrix)

   

A A

A A







A B

B

A   

B C

 

A B

C

A     

 

0 otherwise

if 1

, i j

a aij ij

I IB B

A AI

(17)

Matrix Multiplication:

• Associative:

• Is AB = BA? Maybe, but maybe not!

• multiplication is NOT commutative!

Properties of Matrix Operations

 

 

  

 

 

 

 

...

...

...

bg ae

h g

f e

d c

b

 a

 

  

 

 

 

 

...

...

...

fc ea

d c

b a

h g

f e

A(BC)=(AB)C

(18)

Row and Column Matrices

• Column Matrix

– p

T

: row matrix

• Concatenations

– Associative

• By Row Matrix

 

 

z y x p

ABCp p

Ap p

 

 

 

T T

T T

T

T T T

A B

C p

p

A B

AB

 

 X Y Z 

T

p

(19)

Inverse of a Matrix

• Identity matrix:

AI = A

• Some matrices have an inverse:

AA

-1

= I

• Inversion is tricky:

(ABC)

-1

= C

-1

B

-1

A

-1

Derived from non-commutativity property





1 0

0

0 1

0

0 0

1 I

(20)

• Used for inversion

• If det(A) = 0, then A has no inverse

Determinant of a Matrix

 

 

 

d c

b

A a det( A )  ad  bc



 

 

a c

b d

bc A 1 ad 1

(21)

Sum from left to right

Subtract from right to left Note: N! terms

Determinant of a Matrix

ceg bdi

afh cdh

bfg aei

i h

g

f e

d

c b

a

i h

g

f e

d

c b

a

i h

g

f e

d

c b

a

i h

g

f e

d

c b

a

Referensi

Dokumen terkait