matrix algebra - hallym.ac.krgraphics.hallym.ac.kr/teach/2009/gp1/src/03matrix.pdfmultiplicationto...

21
Matrix Algebra 3 d W k 2009 3 rd Week , 2009 Objectives (1) Objectives (1) To obtain an understanding of matrices understanding of matrices and To obtain an understanding of matrices understanding of matrices and the operations defined on them T di h t ti ti T o discover how a vector vector -matrix matrix multiplication multiplication can be viewed as a linear combination and ho a ecto mat i combination, and how a vector-matrix multiplication can be used to convert the coordinates of points and ectors from one coordinates of points and vectors from one coordinate system to another l h i i To learn how we can use matrix matrix-matrix matrix multiplication multiplication to combine several f i i i transformations into one matrix

Upload: ngodiep

Post on 27-Mar-2018

217 views

Category:

Documents


2 download

TRANSCRIPT

Matrix Algebra

3 d W k 20093rd Week, 2009

Objectives (1)Objectives (1)

■ To obtain an understanding of matricesunderstanding of matrices and■ To obtain an understanding of matricesunderstanding of matrices and the operations defined on themT di h tt t it i■ To discover how a vectorvector--matrix matrix multiplicationmultiplication can be viewed as a linear combination and ho a ecto mat icombination, and how a vector-matrix multiplication can be used to convert the coordinates of points and ectors from onecoordinates of points and vectors from one coordinate system to another

l h ii ii■ To learn how we can use matrixmatrix--matrix matrix multiplicationmultiplication to combine several

f i i itransformations into one matrix

Objectives (2)Objectives (2)

■ To learn what the identity matrixidentity matrix is and what■ To learn what the identity matrixidentity matrix is, and what the transposetranspose and inverseinverse of a matrix areT b f ili ith b t f l■ To become familiar with a subset of classes and functions provided by the D3DX libraryD3DX librarythat a e sed fo mat i mathematicsthat are used for matrix mathematics

Definition (1)Definition (1)

■ An m×n matrix M■ An m×n matrix M■ A rectangular array of real numbers with m rows

and n columns (m×n : dimension)and n columns (m×n : dimension)

⎥⎥⎤

⎢⎢⎡

= 232221

131211

mmm

mmm

M

■ An elementelement or entryentry

⎥⎥⎦⎢

⎢⎣ 333231

232221

mmm

mmmM

■ An elementelement or entryentry■ mij : the element in the i-th row and j-th column of a

matrix

■ Row vectors and column vectors

[ ] ⎥⎤

⎢⎡ 1v

rr [ ]⎥⎥⎥

⎦⎢⎢⎢

==

3

24321

v

vvuuuuu

Example 2 1Example 2.1

■ Consider the following matrices:■ Consider the following matrices:

⎥⎥⎤

⎢⎢⎡

0010

0005.3

⎥⎤

⎢⎡ 1211 bb

[ ] ⎥⎤

⎢⎡ 1v

⎥⎥⎥

⎦⎢⎢⎢

⎣ −

=

1352

05.000

0010A

⎥⎥⎥

⎦⎢⎢⎢

=

3231

2221

bb

bbB [ ]4321 uuuuu =r

⎥⎥⎥

⎦⎢⎢⎢

=

3

2

v

vvr

■ Dimension of matrices A, B, , and :4 x 4, 3 x 2, 1 x 4, and 3 x 1 matrices

⎦⎣ 1352ur

vr

■ The elements in the 4th row and 2nd column of matrix Aand in the 2nd row and 1st column of matrix B:

a42 = –5 and b21

■ Row vectors or column vectorsTo represent a vector in matrix form■ To represent a vector in matrix form

Definition (2)Definition (2)

■ The rows of a matrix == vectors■ The rows of a matrix == vectors

⎥⎥⎤

⎢⎢⎡

⎥⎥⎤

⎢⎢⎡ 1131211 row

v

v

vvv

vvvr

r

h d

⎥⎥⎥

⎦⎢⎢⎢

=⎥⎥⎥

⎦⎢⎢⎢

⎣ 3

2

333231

232221

row

row

v

v

vvv

vvvr

[ ]r [ ]r■ where , , and

Th l f i

[ ]1312111 vvvvrow =r

[ ]3332313 vvvvrow =r

[ ]2322212 vvvvrow =r

■ The columns of a matrix == vectors

[ ]321232221

131211

colcolcol vvvvvv

vvvrrr

=⎥⎥⎤

⎢⎢⎡

[ ]321

333231

232221 colcolcol

vvv ⎥⎥⎦⎢

⎢⎣

⎥⎤

⎢⎡ 11v

⎥⎤

⎢⎡ 12v

⎥⎤

⎢⎡ 13v

■ where , , and⎥⎥⎥

⎦⎢⎢⎢

=

31

211

v

vvcol

r

⎥⎥⎥

⎦⎢⎢⎢

=

32

222

v

vvcol

r

⎥⎥⎥

⎦⎢⎢⎢

=

33

233

v

vvcol

r

OperationsOperations

■ Equality■ Equality■ Let A and B be m×n matrices, then A = B if only if aij

= b (i = 1 m j = 1 n) bij (i 1…m, j 1…n)

■ AdditionL t A B d C b × t i th A + B C■ Let A, B, and C be m×n matrices, then A + B = Cwhere cij = aij + bij (i = 1…m, j = 1…n)

Scalar multiplication■ Scalar multiplication■ Let k be a scalar and A and B be m×n matrices,

then kA = B where b = ka (i = 1 m j = 1 n)then kA = B where bij = kaij (i = 1…m, j = 1…n)

■ Subtraction( ) ( )■ ( ) ( )BABABA −+=⋅−+=− 1

Example 2 2Example 2.2

■ Let■ Let

⎥⎦

⎤⎢⎣

⎡ −=⎥

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡=

036

312 and ,

32

51 ,

85

26 ,

32

51DCBA

■ A + B =⎦⎣−⎦⎣−⎦⎣ −⎦⎣− 036328532

⎥⎦

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡ ++=⎥

⎤⎢⎣

⎡+⎥

⎤⎢⎣

⎡53

77

8352

2561

85

26

32

51

■ Clearly, A = C

⎥⎦

⎢⎣ −⎥

⎦⎢⎣ −+−⎥

⎦⎢⎣ −⎥

⎦⎢⎣− 5383528532

3and251 ==−====== cacacacaQ

■ 3D =

.3 and ,2 ,5 ,1 2222212112121111 ======== cacacacaQ

( )( ) ⎥

⎤⎢⎡ −

=⎥⎤

⎢⎡ −⋅⋅⋅

=⎥⎤

⎢⎡ − 936331323312

3

■ A – B =

( ) ⎥⎦

⎢⎣−

⎥⎦

⎢⎣ ⋅⋅−⋅⎥

⎦⎢⎣− 0918033363036

( ) ⎥⎤

⎢⎡−

=⎥⎤

⎢⎡ −−

=⎥⎤

⎢⎡

−⎥⎤

⎢⎡ 3525612651

( ) ⎥⎦

⎢⎣−

⎥⎦

⎢⎣ −−−−⎥

⎦⎢⎣ −⎥

⎦⎢⎣− 11783528532

Matrix MultiplicationMatrix Multiplication==

⎥⎤

⎢⎡ naa L 111

⎥⎤

⎢⎡ pbb L 111

A : m×n matrix B : n×p matrix

⎥⎥⎥

⎦⎢⎢⎢

=

mnm aa

A

L

MOM

1⎥⎥⎥

⎦⎢⎢⎢

=

npn bb

B

L

MOM

1

RowVector⎦⎣ ⎦⎣ p

CAB = coljrowi

n

kjikij babacrr⋅==∑

Column VectorElement

k=1

⎥⎤

⎢⎡ pcc L 111

⎥⎥⎥

⎦⎢⎢⎢

=

mpm cc

C

L

MOM

1 ⎦⎣C : m×p matrix

Example 2 3Example 2.3

■ Let ⎤⎡ 012■ Let

⎥⎥⎥

⎢⎢⎢

⎡−=⎥

⎤⎢⎣

⎡ −−=

321

120

012

and 123

451BA

AB

⎥⎦⎢⎣− 321

⎥⎤

⎢⎡

⎥⎤

⎢⎡ −−

120

012451

■ AB =

( ) ( ) ( ) ( ) ( ) ( )⎤⎡

⎥⎥⎥

⎦⎢⎢⎢

⎣−−⎥

⎦⎢⎣

310451221451102451

321

120123

( ) ( ) ( ) ( ) ( ) ( )( ) ( ) ( ) ( ) ( ) ( )

⎤⎡

⎥⎦

⎤⎢⎣

⎡⋅−⋅−⋅⋅−−−⋅−−−⋅−−

=3,1,01,2,32,2,11,2,31,0,21,2,3

3,1,04,5,12,2,14,5,11,0,24,5,1

⎥⎦

⎤⎢⎣

⎡ −−=

515

7192

d f d ( 3 2 )■ BA = not defined ( 3≠2 )

BAAB ≠

Vector Matrix Multiplication (1)Vector-Matrix Multiplication (1)

■■ Linear combinationLinear combination■■ Linear combinationLinear combination

[ ]131211 vvv

Brrrr

++⎥⎤

⎢⎡

[ ] 321

333231

232221 rowrowrow vzvyvx

vvv

vvvzyxBu ++=⎥⎥⎥

⎦⎢⎢⎢

=

⎤⎡[ ] 232221

131211

vvv

vvv

zyxBur

⎥⎥⎥⎤

⎢⎢⎢⎡

=

( ) ( ) ( ) ( ) ( ) ( )[ ][ ]

332313322212312111

333231

,,,,,,,,,,,, vvvzyxvvvzyxvvvzyx

vvv

⋅⋅⋅=

⎥⎦⎢⎣

[ ][ ] [ ] [ ][ ] [ ] [ ]

333231232221131211

332313322212312111

zvzvzvyvyvyvxvxvxv

zvyvxvzvyvxvzvyvxv

++=++++++=

[ ] [ ] [ ]321

333231232221131211

rowrowrow vzvyvx

vvvzvvvyvvvxrrr⋅+⋅+⋅=

++=

Vector Matrix Multiplication (2)Vector-Matrix Multiplication (2)

■ Change of frame■ Change of frame( )yxpp A ,==

rr ( )yxpp B ′′== ,rr

( ) ( ) ( )OOOvvvuuu ===rrr

■ Vectors: vyuxpB

rrr+=

( ) ( ) ( )yxyxyx OOOvvvuuu , ,, ,, ===

wzvyuxpB

rrrr++=

0uuu ⎤⎡

3D

[ ] [ ]00

0

0

0 zyxwzvyuxwww

vvv

uuu

zyxCpzyx

zyx

zyx

′′′=++=

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

=rrrr

■ Points: vyuxOpB

rrrr++= wzvyuxOpB

rrrrr+++=

1OOO zyx ⎥⎥⎦⎢

⎢⎣

3DypB ypB

[ ] [ ]10

0

0

1 zyxOwzvyuxvvv

uuu

zyxCp zyx

zyx

′′′=+++=⎥⎥⎥⎤

⎢⎢⎢⎡

=rrrrr [ ] [ ]

1

0yy

OOO

wwwyp

zyx

zyx

⎥⎥⎥

⎦⎢⎢⎢

Vector Matrix Multiplication (3)Vector-Matrix Multiplication (3)

■ 4D Homogeneous coordinatesHomogeneous coordinates■ 4D Homogeneous coordinatesHomogeneous coordinates

Vectors: 0

( )wzyxr ,,,=r

■ Vectors: w = 0

■ Points: w = 1uuu zyx

⎥⎤

⎢⎡ 0

[ ] [ ]wzyxpOwwzvyux

OOO

www

vvvwzyxCp B

zyx

zyx

zyx

A ′′′==+++=

⎥⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎢⎡

=rrrrrr

1

0

0

■ C: change of frame matrix from frame A to frame Bth i i d i f f A l ti t f B

OOO zyx ⎥⎥⎦⎢

⎢⎣ 1

■ the origin, x-, y-, and z-axis of frame A relative to frame B( )( )0,,,

1,,,

zyx

zyx

uuuu

OOOO

=

=r

r

⎥⎥⎤

⎢⎢⎡

0

0

zyx

zyx

vvv

uuuChange ofFrame Matrix

( )( )0,,,

0,,,

zyx

zyx

wwww

vvvv

=

=r

r

⎥⎥⎥⎥

⎦⎢⎢⎢⎢

⎣ 1

0

zyx

zyx

OOO

www

Matrix-Matrix Multiplication and Associativity

■ Suppose■ Suppose …■ Three frames: A, B, and C.

F: change of frame matrix from frame A to frame B■ F: change of frame matrix from frame A to frame B■ G: change of frame matrix from frame B to frame C

Change ofChange of Frame

Apr

Cpr

( ) pGFprr

i l i li i i i i

( )CB

CA

pGp

pGFprr

==

■ Matrix multiplication is associative( ) CA pFGp

rr=

■ Performance!!CA pHprr

=

The Transpose of a MatrixThe Transpose of a Matrix

■ Interchanging the rows and the columns of a■ Interchanging the rows and the columns of a matrix

M : m×n matrix MT : n×m matrix

⎥⎥⎤

⎢⎢⎡

=nee

M MOM

L 111Transpose

⎥⎥⎤

⎢⎢⎡

=m

T

ee

M MOM

L 111

⎥⎥⎦⎢

⎢⎣ mnm ee

M

L

MOM

1 ⎥⎥⎦⎢

⎢⎣ nmn ee

M

L

MOM

1

Example 2 4Example 2.4

■ Find the transpose for the following three■ Find the transpose for the following three matrices:

⎥⎤

⎢⎡ − 812

A ⎥⎤

⎢⎡

fd

cba

B ⎥⎥⎤

⎢⎢⎡2

1

C⎥⎦

⎢⎣ −

=463

A

⎥⎥⎥

⎦⎢⎢⎢

=ihg

fedB

⎥⎥⎥

⎦⎢⎢⎢

=

4

3C

⎤⎡ 32■ AT =

⎦⎣

⎥⎥⎥⎤

⎢⎢⎢⎡− 61

32

■ BT =

⎥⎦⎢⎣ − 48

⎥⎤

⎢⎡ gda

CT⎥⎥⎥

⎦⎢⎢⎢

⎣ ifc

heb

■ CT =⎦⎣

[ ]4321

The Identity MatrixThe Identity Matrix

■ A square matrix that has zeros for all elements■ A square matrix that has zeros for all elements except along the main diagonal and the elements along main diagonal are all oneselements along main diagonal are all ones■ Ex)

⎥⎤

⎢⎡

⎤⎡0001

001

⎥⎥⎥⎥

⎢⎢⎢⎢

⎥⎥⎥

⎢⎢⎢

⎥⎦

⎤⎢⎣

⎡0100

0010

100

010

001

10

01

M lti li ti id tit

⎥⎦

⎢⎣

⎥⎦⎢⎣ 1000100

■ Multiplicative identity■ Commutative

MIMMI == MIMMI ==

Example 2 5Example 2.5

■ Let■ Let⎥⎦

⎤⎢⎣

⎡=

40

21M ⎥

⎤⎢⎣

⎡=

10

01I

■ Verify that MI = IM = M

⎦⎣ ⎦⎣

( ) ( ) ( ) ( )( ) ( ) ( ) ( ) ⎥

⎤⎢⎣

⎡=⎥

⎤⎢⎣

⎡⋅⋅⋅⋅

=⎥⎦

⎤⎢⎣

⎡⎥⎦

⎤⎢⎣

⎡=

40

21

10400140

1,02,10,12,1

10

01

40

21MI ( ) ( ) ( ) ( ) ⎦⎣⎦⎣⎦⎣⎦⎣ 401,04,00,14,01040

( ) ( ) ( ) ( )⎥⎤

⎢⎡

=⎥⎤

⎢⎡ ⋅⋅

=⎥⎤

⎢⎡⎥⎤

⎢⎡

=214,20,10,10,12101

IM ( ) ( ) ( ) ( ) ⎥⎦

⎢⎣

=⎥⎦

⎢⎣ ⋅⋅

=⎥⎦

⎢⎣⎥⎦

⎢⎣

=404,21,00,11,04010

IM

MIMMI MIMMI ==∴

The Inverse of a Matrix (1)The Inverse of a Matrix (1)

■ Multiplicative inverse operation■ Multiplicative inverse operation■ Only square matrices have inverses

The inverse is unique■ The inverse is unique■ Not every square matrix has an inverse

■■ InvertibleInvertible: a matrix that have an inverse■■ InvertibleInvertible: a matrix that have an inverse■■ SingularSingular: a matrix that does not have an inverse

■ Notation: M-1 (n×n matrix)■ Notation: M (n×n matrix)■ The inverse matrix of an n×n matrix M

M lti l i t i ith it i■ Multiplying a matrix with its inverse■ Commutative

IMMMM −− 11 IMMMM == 11

The Inverse of a Matrix (2)The Inverse of a Matrix (2)

■ Useful for solving matrices in a matrix equation■ Useful for solving matrices in a matrix equation■ Ex) Given and the change of frame matrix M from

frame A to frame B solve AprBp

r

frame A to frame B, solve .Ap

AB

MMpMp

Mpprr

rr

=

=−− 11

AB

AB

IpMp

MMpMprr

=

=−

1

1

■ M-1: the change of frame matrix from frame B to frame AAB pMprr

=−1

+Y +Z '

+Z+Y '

X '

M

M 1

+XFrame A

+X '

Frame BM-1

The Inverse of a Matrix (3)The Inverse of a Matrix (3)

■ The property of the inverse of a product■ The property of the inverse of a product

( ) 111 −−− = FGFG

FG

+Z

+Y +Z '+Y 'F

+Y "

G

+XFrame A

+X '

Frame B

F-1+Z "

+X "Frame C

G-1

Frame A Frame B Frame C

G 1F 1G-1F-1

D3DX Matrices (1)D3DX Matrices (1)

■ D3DXMATRIX class■ D3DXMATRIX class

D3DX Matrices (2)D3DX Matrices (2)

■ Useful functions■ Useful functions■ Obtaining the 4x4 identity matrix

■ Computing the transpose of a matrix

■ Computing the inverse of a matrix

M l i l i 1 4 d 4 4 i■ Multiplying 1x4 vector and a 4x4 matrix

Sample Program (1)Sample Program (1)#include <d3dx9.h>#include <iostream>#using namespace std;

// Overload the "<<" operators so that we can use cout to // output D3DXVECTOR4 and D3DXMATRIX objects.

ostream& operator<<(ostream& os D3DXVECTOR4& v)ostream& operator<<(ostream& os, D3DXVECTOR4& v){

os << "(" << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ")";return os;

}

ostream& operator<<(ostream& os D3DXMATRIX& m)ostream& operator<<(ostream& os, D3DXMATRIX& m){

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

for(int j = 0; j < 4; ++j)os << m(i, j) << " ";dlos << endl;

}return os;

}

int main()(){

D3DXMATRIX A(1.0f, 0.0f, 0.0f, 0.0f,0.0f, 2.0f, 0.0f, 0.0f,0.0f, 0.0f, 4.0f, 0.0f,1.0f, 2.0f, 3.0f, 1.0f);

Sample Program (2)Sample Program (2)D3DXMATRIX B;;D3DXMatrixIdentity(&B);

// matrix-matrix multiplicationD3DXMATRIX C = A*B;

D3DXMATRIX D E F;D3DXMATRIX D, E, F;

D3DXMatrixTranspose(&D, &A);

D3DXMatrixInverse(&E, 0, &A);

F = A * E;F = A * E;

D3DXVECTOR4 P(2.0f, 2.0f, 2.0f, 1.0f);D3DXVECTOR4 Q;D3DXVec4Transform(&Q, &P, &A);

t "A " dl A dlcout << "A = " << endl << A << endl;cout << "B = " << endl << B << endl;cout << "C = A*B = " << endl << C << endl;cout << "D = transpose(A)= " << endl << D << endl;cout << "E = inverse(A) = " << endl << E << endl;cout << "F = A*E = " << endl << F << endl;;cout << "P = " << P << endl;cout << "Q = P*A = " << Q << endl;

return 0;}

ResultResult

Exercise 1 (1)Exercise 1 (1)

■ Let■ Let 00010003⎥⎤

⎢⎡

⎥⎤

⎢⎡

[ ]1112 and ,0100

0010 ,

0400

0020−=

⎥⎥⎥⎥

⎢⎢⎢⎢

=

⎥⎥⎥⎥

⎢⎢⎢⎢ −

= uTSr

C t th f ll i t i d t ST

11521000⎥⎦

⎢⎣ −−⎥

⎦⎢⎣

■ Compute the following matrix products: ST, TS, , , and .

■ Dose TS = ST ?Sur

Tur ( )STu

r

■ Dose TS = ST ?

Exercise 1 (2)Exercise 1 (2)n rElement

Matrix Multiplication

⎤⎡ aa ⎤⎡ bb

CAB = coljrowik

kjikij babacrr⋅==∑

=1

Element

Column Vector

⎥⎥⎥

⎢⎢⎢

⎡=

naa

A MOM

L 111

⎥⎥⎥

⎢⎢⎢

=p

bb

bb

B MOM

L 111RowVector⎥⎦⎢⎣ mnm aa L1

⎥⎦⎢⎣ npn bb L1

⎥⎥⎤

⎢⎢⎡

−⎥⎥⎤

⎢⎢⎡

0020

0003

0010

0001

⎥⎥⎤

⎢⎢⎡

⎥⎥⎤

⎢⎢⎡

− 0010

0001

0020

0003

⎥⎥⎥

⎦⎢⎢⎢

⎣⎥⎥⎥

⎦⎢⎢⎢

⎣ −−

=

1000

0400

0020

1152

0100

0010TS

⎥⎥⎥

⎦⎢⎢⎢

⎣ −−⎥⎥⎥

⎦⎢⎢⎢

=

1152

0100

0010

1000

0400

0020ST

⎥⎥⎥⎤

⎢⎢⎢⎡

−=

0400

0020

0003

⎥⎥⎥⎤

⎢⎢⎢⎡

−=

0400

0020

0003

⎥⎥

⎦⎢⎢

⎣ − 14106

0400⎥⎥

⎦⎢⎢

⎣ −− 1152

0400

TSST ≠∴

Exercise 1 (3)Exercise 1 (3)0003⎥⎤

⎢⎡ 0001

⎥⎤

⎢⎡

[ ]

1000

0400

00201112

⎥⎥⎥⎥

⎦⎢⎢⎢⎢

−−=Su

r [ ]

1152

0100

00101112

⎥⎥⎥⎥

⎦⎢⎢⎢⎢

⎣ −−

−=Tur

[ ]1426

1000

=⎦⎣

[ ]1064

1152

−=⎦⎣

00010003 ⎤⎡⎤⎡

( ) [ ]0100

0010

0001

0400

0020

0003

1112

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

−−=STu

r

0003

11521000

⎥⎤

⎢⎡

⎥⎦

⎢⎣ −−⎥⎦

⎢⎣

[ ]

1152

0400

00201112

⎥⎥⎥⎥

⎦⎢⎢⎢⎢

⎣ −−

−−=

[ ]1338

5

−=⎦⎣

Exercise 1 Program (1)Exercise 1 – Program (1)

Exercise 1 Program (2)Exercise 1 – Program (2)

Exercise 1 ResultExercise 1 – Result

Exercise 3 (1)Exercise 3 (1)

■ Using S and T from exercise 1 compute ST TT■ Using S and T from exercise 1, compute S , T , and (ST)T. What is (ST)T and (TT)T? Does (ST)T =TTST ?T S ?

⎤⎡ ee L

M : m×n matrix

⎤⎡ ee L

MT : n×m matrix

⎥⎥⎥

⎢⎢⎢

⎡=

n

ee

ee

M MOM

L 111Transpose

⎥⎥⎥

⎢⎢⎢

⎡=

mT

ee

ee

M MOM

L 111

⎥⎦⎢⎣ mnm ee L1 ⎥⎦⎢⎣ nmn ee L1

⎤⎡⎤⎡ 20010001TT

⎤⎡⎤⎡ 00030003

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

−−

=

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

=1100

5010

2001

0100

0010

0001

TTSST =

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

−=

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

−=

0400

0020

0003

0400

0020

0003

⎥⎦

⎢⎣

⎥⎦

⎢⎣ −− 10001152

⎥⎦

⎢⎣

⎥⎦

⎢⎣ 10001000

Exercise 3 (2)Exercise 3 (2)

⎥⎥⎤

⎢⎢⎡

−−⎥⎥⎤

⎢⎢⎡

−⎟⎞

⎜⎜⎛

⎥⎥⎤

⎢⎢⎡

⎥⎥⎤

⎢⎢⎡

− 5020

2003

0020

0003

0010

0001

0020

0003TT

( )⎥⎥⎥

⎦⎢⎢⎢

−−−

=

⎥⎥⎥

⎦⎢⎢⎢

⎣ −−

−=

⎟⎟⎟

⎠⎜⎜⎜⎜

⎝⎥⎥⎥

⎦⎢⎢⎢

⎣ −−⎥⎥⎥

⎦⎢⎢⎢

−=

1000

1400

5020

1152

0400

0020

1152

0100

0010

1000

0400

0020TST

T

( ) SS

TTT

TT =⎥⎥⎥⎤

⎢⎢⎢⎡

−=

⎥⎥⎥⎤

⎢⎢⎢⎡

−=

⎟⎟⎞

⎜⎜⎜⎜⎛

⎥⎥⎥⎤

⎢⎢⎢⎡

−=

0400

0020

0003

0400

0020

0003

0400

0020

0003

TTT⎤⎡⎤⎡⎞

⎜⎛ ⎤⎡ 000120010001

( )⎥⎥

⎦⎢⎢

⎣⎥⎥

⎦⎢⎢

⎣⎟⎠

⎜⎜

⎝⎥⎥

⎦⎢⎢

⎣ 1000

0400

1000

0400

1000

0400

( ) TTTT =

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

=

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

−−

=⎟⎟⎟

⎜⎜⎜⎜⎜⎛

⎥⎥⎥⎥⎤

⎢⎢⎢⎢⎡

=0100

0010

0001

1100

5010

2001

0100

0010

0001

⎥⎦

⎢⎣ −−⎥

⎦⎢⎣⎠

⎜⎝

⎥⎦

⎢⎣ −− 115210001152

⎥⎥⎤

⎢⎢⎡

−−⎥⎥⎤

⎢⎢⎡

−⎥⎥⎤

⎢⎢⎡

− 5020

2003

0020

0003

5010

2001

( )TTT STST =

⎥⎥⎥

⎦⎢⎢⎢

−−−

=

⎥⎥⎥

⎦⎢⎢⎢

⎥⎥⎥

⎦⎢⎢⎢

−−

=

1000

1400

5020

1000

0400

0020

1000

1100

5010( ) TTT STST =∴

Exercise 3 Program (1)Exercise 3 – Program (1)

Exercise 3 Program (2)Exercise 3 – Program (2)

Exercise 3 ResultExercise 3 – Result

ExerciseExercise

■ Program the following questions:■ Program the following questions:(Exercise 4) Using S and T from exercise 1,

comp te S 1 T 1 and (ST) 1 What is (S 1) 1 andcompute S-1, T-1, and (ST)-1. What is (S-1)-1 and (T-1)-1? Does (ST)-1 = T-1S-1 ?

(Exercise 6) Redo exercise 11 from Chapter 1 pusing the following equation:

uuu zyx⎥⎤

⎢⎡

0

0

[ ] [ ]wzyxpOwwzvyux

OOO

www

vvvzyxCp B

zyx

zyx

zyxA ′′′==+++=

⎥⎥⎥⎥⎥

⎦⎢⎢⎢⎢⎢

=rrrrrr

1

0

01

zyx ⎥⎦⎢⎣

C: change of frame matrix from frame A to frame B

연습문제 (1)연습문제 (1)

■ 다음 질문의 프로그램을 작성하여 답하시오■ 다음 질문의 프로그램을 작성하여 답하시오.(Exercise 4) Exercise 1의 S 와 T 를 사용하여, S-1,

T 1 (ST) 1를 계산하시오 (S 1) 1 과 (T 1) 1 는 무엇T-1, (ST)-1를 계산하시오. (S-1)-1 과 (T-1)-1 는 무엇과 같은가? (ST)-1 = T-1S-1 식은 성립하는가?

(Exercise 6) 다음 공식을 이용하여 Chapter 1의pexercise 11을 다시 계산하시오. (다음 쪽 참조)

uuu zyx⎥⎤

⎢⎡

0

0

[ ] [ ]wzyxpOwwzvyux

OOO

www

vvvzyxCp B

zyx

zyx

zyxA ′′′==+++=

⎥⎥⎥⎥⎥

⎦⎢⎢⎢⎢⎢

=rrrrrr

1

0

01

zyx ⎥⎦⎢⎣

C: 프레임 A 에서 프레임 B 로의 change of frame matrix

연습문제 (2)연습문제 (2)

■ Chapter 1 (Exercise 11) 프레임 A와 B가 있다고■ Chapter 1 (Exercise 11) 프레임 A와 B가 있다고가정할 때, 와 는 프레임 A에 있는 포인트와 힘의 좌표이다. 프레임 A를 표

( )0,2,1 −=Apr ( )0,2,1=Aq

r

에 있는 인 와 힘의 좌 이다 레임 를현하는 4개 벡터 에 대한 프레임 B에서의 좌표가 아래와 같을 때, 프레임 B에서의 포인

와 힘의 좌 와 계산( ) ( )

wvuOrrrr

, , ,

트와 힘의 좌표 와 를 계산하시오.

( )zyxpB ,,=r ( )zyxqB ,,=

r

1111 ⎞⎛⎞⎛( ) ( )1,0,0 ,0,2

1,

2

1 ,0,

2

1,

2

1 ,0,2,6 =⎟

⎠⎞

⎜⎝⎛−=⎟

⎠⎞

⎜⎝⎛=−= wvuO

rrrr

(힌트: 4개의 벡터를 이용하여 change of frame matrix를 구성한 다음, D3DXVec4Transform( ) 함수를 이용하여 계산수를 이용하여 계산)

제출 방법제출 방법

■ 문제 4 ex04 cpp 문제 6 ex06 cpp■ 문제 4 ex04.cpp, 문제 6 ex06.cpp

실행 결과 화면 캡쳐 04 j 06 j■ 실행 결과 화면 캡쳐 ex04.jpg, ex06.jpg■ Alt + PrintScreen 그림판 붙여넣기 저장

■ 위 4개 파일을 압축 ‘본인학번.zip’

■ 수업시간 전까지 조교에게 e-mail로 제출수업시간 전까지 에게 제출