cs380: introduction to computer graphics respect chapter 4...

13
18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction to Computer Graphics Respect Chapter 4 Min H. Kim KAIST School of Computing Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 SUMMARY Affine Transformation 2

Upload: others

Post on 11-Jul-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CS380:IntroductiontoComputerGraphicsRespectChapter4

MinH.KimKAISTSchoolofComputing

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

SUMMARYAffineTransformation

2

Page 2: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

2

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Lineartransformation•  3-by-3transformmatrixà4-by-4affinetransform

3

b1

b2

b3o⎡

⎣⎤⎦

c1c2c31

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

b1

b2

b3o⎡

⎣⎤⎦

a b c 0e f g 0i j k 00 0 0 1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

c1c2c31

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

.

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Translationtransformation•  translationtransformationtopoints

4

b1

b2

b3o⎡

⎣⎤⎦

c1c2c31

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

⇒ b1

b2

b3o⎡

⎣⎤⎦

1 0 0 tx0 1 0 ty0 0 1 tz0 0 0 1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

c1c2c31

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

.

Page 3: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

3

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Affinetransformmatrix•  Anaffinematrixcanbefactoredintoalinearpartandatranslationalpart:

5

a b c de f g hi j k l0 0 0 1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

1 0 0 d0 1 0 h0 0 1 l0 0 0 1

⎢⎢⎢⎢

⎥⎥⎥⎥

a b c 0e f g 0i j k 00 0 0 1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

.

l t0 1

⎣⎢

⎦⎥ =

i t0 1

⎣⎢

⎦⎥

l 00 1

⎣⎢

⎦⎥

A = TL

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Normals•  Normal:avectorthatisorthogonaltothetangentplaneofthesurfacesatthatpoint.–  thetangentplaneisaplaneofvectorsthataredefinedbysubtracting(infinitesimally)nearbysurfacepoints:

6

n ⋅( p1 − p2 ) = 0

nx 'ny 'nz '

⎢⎢⎢

⎥⎥⎥= l− t

nxnynz

⎢⎢⎢

⎥⎥⎥.

Page 4: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

4

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RESPECTChapter4

7

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Scalingapointoverframe•  Wearetransformingapointinaframe•  Withamatrix

•  Performingatransform:

•  Supposeanotherframe:8

S =

2 0 0 00 1 0 00 0 1 00 0 0 1

⎢⎢⎢⎢

⎥⎥⎥⎥

p f t

p =f tc

f tc⇒

f tSc

at =f t A

thestretchesbyfactoroftwoinfirstaxisof

f t

Page 5: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

5

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Scalingapointoverframe•  Wecouldexpressthepointwithanewcoordinatevector

•  Nowtransformsthepointwithrespectto

9

p =f tc = atd

at =f t A

f tc =

f t Ad

1A−=d c

atS

atd⇒ atSd

p

f t = at A−1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Left-ofrule•  Pointistransformedwithrespecttothetheframethatappearsimmediatelytotheleftofthetransformationmatrixintheexpression.

•  Weread

•  Weread

10

tt S⇒f fr r

Sistransformedbywithrespectto tfr

f t

istransformedbywithrespectto

1 1tt t A SA− −= ⇒f aar rr

S tar f t

Page 6: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

6

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Scalingapointoverframe

11

t tp S= ⇒f c cfrr

%Sistransformedbywithrespectto p

f t

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Scalingapointoverframe

12

p =at A−1c⇒ atSA−1c

Sistransformedbywithrespectto p at

Page 7: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

7

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Scalingapointoverframe

13

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Rotatingapointoverframe•  Thesamereasoningtotransformationsofframesthemselves:

•  Inanotherframe:

14

istransformedbywithrespectto

tt R⇒f fr r

R f t tf

r

istransformedbywithrespectto

1 1tt t A RA− −= ⇒f aar rr

R f t

tar

Page 8: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

8

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Rotatingapointoverframe

15istransformedbywithrespectto

t tp R= ⇒f c cfrr

%R p

f t

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Rotatingapointoverframe

16

istransformedbywithrespectto1 1t tp A RA− −= ⇒a c a crr%

R p at

Page 9: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

9

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Rotatingapointoverframe

17

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

AuxiliaryFrame•  Youwanttobuildthesolarsystem– TheMoonrotatesaroundtheEarth’sframe– TheEarthrotatesaroundtheSun’sframe

18

TheSun

TheEarth

TheMoon

Page 10: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

10

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

TransformsusinganAuxiliaryFrame•  Sometimesweneedtotransformaframeinsomespecificway,representedbyamatrix,withrespecttosomeauxiliaryframe

•  Thetransformframecanthenbeexpressedas

19

f tM

at

at ⇒

f t A

f t

=at A−1

⇒atMA−1

=f t AMA−1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

MultipleTransformations•  Rotationandtranslationwithframe

•  NBingeneral,matrixmultiplicationisnotcommutative!!!

•  Therearetwodifferentwaystoapplymultipletransformations– Localtransformation– Globaltransformation

20

f t ⇒

f tTR

f tTR ≠

f t RT

Page 11: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

11

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

LocalTransformations•  Localtransformations

•  Inthefirststep,

21

f t ⇒

f tTR

f t ⇒

f tT =

f 't

istransformedbywithrespecttoT f t

f t

astheresultingframe: f 't

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

LocalTransformations•  Localtransformations

•  Inthesecondstep,

22

f t ⇒

f tTR

f t ⇒

f tTR,' .t t R⇒ ff

r r

istransformedbywithrespecttoR f t

f 't

Page 12: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

12

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

GlobalTransformations•  Globaltransformations

•  Inthefirststep(inthereverseorder)

23

f t ⇒

f t R =

f t

istransformedbywithrespecttoR f t

f t

astheresultingframe: f t

f t ⇒

f tTR

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

GlobalTransformations•  Globaltransformations

•  Inthesecondstep

24

t t tR TR= ⇒ ff for rr

istransformedbywithrespecttoT f t

f t

f t ⇒

f tTR

Page 13: CS380: Introduction to Computer Graphics Respect Chapter 4 ...vclab.kaist.ac.kr/cs380/slide05-respect.pdf18/03/20 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler,

18/03/20

13

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Twointerpretationsoftransformations

•  Twodifferentwaysformultipletransformations:1.  (Localtransformations)Translatewithrespectto

thenrotatewithrespecttotheintermediateframe

2.  (Globaltransformations)Rotatewithrespecttothentranslatewithrespecttotheoriginalframe

25

f t

f 't

f t

f t

Localtransformations Globaltransformations f t ⇒

f tTR