Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture •...

41
Introduction to Computer Graphics GAMES101, Lingqi Yan, UC Santa Barbara Transformation Lecture 3: http://www.cs.ucsb.edu/~lingqi/teaching/games101.html

Transcript of Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture •...

Page 1: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

Introduction to Computer GraphicsGAMES101, Lingqi Yan, UC Santa Barbara

TransformationLecture 3:

http://www.cs.ucsb.edu/~lingqi/teaching/games101.html

Page 2: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Announcements

• Assignment 0 will be released soon

• Do not register the homework submission systemwith QQ email

2

Page 3: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Last Lecture• Vectors

- Basic operations: addition, multiplication

• Dot Product- Forward / backward (dot product positive / negative)

• Cross Product- Left / right (cross product outward / inward)

• Matrices

3

Page 4: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

This Week• Transformation!

• Today

- Why study transformation

- 2D transformations: rotation, scale, shear

- Homogeneous coordinates

- Composing transforms

- 3D transformations

4

Page 5: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Today• Why study transformation

- Modeling

- Viewing

• 2D transformations

• Homogeneous coordinates

5

Page 6: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Why Transformation?

Modeling: translation 6

Page 7: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Why Transformation?

Modeling: rotation 7

Page 8: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Why Transformation?

Modeling: scaling 8

Page 9: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Why Transformation?

9

Viewing: (3D to 2D) projection

Page 10: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Today• Why study transformation

• 2D transformations

- Representing transformations using matrices

- Rotation, scale, shear

• Homogeneous coordinates

10

Page 11: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 11Ren NgCS184/284A

Scale

S0.5

Page 12: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 12Ren NgCS184/284A

Scale Transform

S0.5

x0 = sx

y0 = sy

Page 13: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 13Ren NgCS184/284A

Scale Matrix

S0.5

x0

y0

�=

s 00 s

� xy

Page 14: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 14Ren NgCS184/284A

Scale (Non-Uniform)

S0.5,1.0

x0

y0

�=

sx 00 sy

� xy

<latexit sha1_base64="1HluD7eaew2ZbEeE5TqBR+iyFhc=">AAACW3icbVFdS8MwFE07dXNOnYpPvgSHzqfRiqAvwtAXHye4D1hHSbO7LZimJUllpexP+qQP/hUx24q4zQshh3PP/chJEHOmtON8WnZha3unWNot71X2Dw6rR8cdFSWSQptGPJK9gCjgTEBbM82hF0sgYcChG7w+zvPdN5CKReJFpzEMQjIWbMQo0Ybyq9ILYMxEFoRESzadTeueh9O6B2L4y92vaZQ/xZfYMULH3MpPV9TrDef9VgR+teY0nEXgTeDmoIbyaPnVd28Y0SQEoSknSvVdJ9aDjEjNKIdZ2UsUxIS+kjH0DRQkBDXIFt7M8IVhhngUSXOExgv2b0VGQqXSMDBKs99Erefm5H+5fqJHd4OMiTjRIOhy0CjhWEd4bjQeMglU89QAQiUzu2I6IZJQbb6jbExw15+8CTrXDdfg55ta8yG3o4TO0Dm6Qi66RU30hFqojSj6QN9W0SpZX3bBLtuVpdS28poTtBL26Q8Oh7dR</latexit><latexit sha1_base64="1HluD7eaew2ZbEeE5TqBR+iyFhc=">AAACW3icbVFdS8MwFE07dXNOnYpPvgSHzqfRiqAvwtAXHye4D1hHSbO7LZimJUllpexP+qQP/hUx24q4zQshh3PP/chJEHOmtON8WnZha3unWNot71X2Dw6rR8cdFSWSQptGPJK9gCjgTEBbM82hF0sgYcChG7w+zvPdN5CKReJFpzEMQjIWbMQo0Ybyq9ILYMxEFoRESzadTeueh9O6B2L4y92vaZQ/xZfYMULH3MpPV9TrDef9VgR+teY0nEXgTeDmoIbyaPnVd28Y0SQEoSknSvVdJ9aDjEjNKIdZ2UsUxIS+kjH0DRQkBDXIFt7M8IVhhngUSXOExgv2b0VGQqXSMDBKs99Erefm5H+5fqJHd4OMiTjRIOhy0CjhWEd4bjQeMglU89QAQiUzu2I6IZJQbb6jbExw15+8CTrXDdfg55ta8yG3o4TO0Dm6Qi66RU30hFqojSj6QN9W0SpZX3bBLtuVpdS28poTtBL26Q8Oh7dR</latexit><latexit sha1_base64="1HluD7eaew2ZbEeE5TqBR+iyFhc=">AAACW3icbVFdS8MwFE07dXNOnYpPvgSHzqfRiqAvwtAXHye4D1hHSbO7LZimJUllpexP+qQP/hUx24q4zQshh3PP/chJEHOmtON8WnZha3unWNot71X2Dw6rR8cdFSWSQptGPJK9gCjgTEBbM82hF0sgYcChG7w+zvPdN5CKReJFpzEMQjIWbMQo0Ybyq9ILYMxEFoRESzadTeueh9O6B2L4y92vaZQ/xZfYMULH3MpPV9TrDef9VgR+teY0nEXgTeDmoIbyaPnVd28Y0SQEoSknSvVdJ9aDjEjNKIdZ2UsUxIS+kjH0DRQkBDXIFt7M8IVhhngUSXOExgv2b0VGQqXSMDBKs99Erefm5H+5fqJHd4OMiTjRIOhy0CjhWEd4bjQeMglU89QAQiUzu2I6IZJQbb6jbExw15+8CTrXDdfg55ta8yG3o4TO0Dm6Qi66RU30hFqojSj6QN9W0SpZX3bBLtuVpdS28poTtBL26Q8Oh7dR</latexit><latexit sha1_base64="1HluD7eaew2ZbEeE5TqBR+iyFhc=">AAACW3icbVFdS8MwFE07dXNOnYpPvgSHzqfRiqAvwtAXHye4D1hHSbO7LZimJUllpexP+qQP/hUx24q4zQshh3PP/chJEHOmtON8WnZha3unWNot71X2Dw6rR8cdFSWSQptGPJK9gCjgTEBbM82hF0sgYcChG7w+zvPdN5CKReJFpzEMQjIWbMQo0Ybyq9ILYMxEFoRESzadTeueh9O6B2L4y92vaZQ/xZfYMULH3MpPV9TrDef9VgR+teY0nEXgTeDmoIbyaPnVd28Y0SQEoSknSvVdJ9aDjEjNKIdZ2UsUxIS+kjH0DRQkBDXIFt7M8IVhhngUSXOExgv2b0VGQqXSMDBKs99Erefm5H+5fqJHd4OMiTjRIOhy0CjhWEd4bjQeMglU89QAQiUzu2I6IZJQbb6jbExw15+8CTrXDdfg55ta8yG3o4TO0Dm6Qi66RU30hFqojSj6QN9W0SpZX3bBLtuVpdS28poTtBL26Q8Oh7dR</latexit>

Page 15: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 15Ren NgCS184/284A

Reflection Matrix

x0 =??

y0 =??

Horizontal reflection: x0

y0

�=

�1 00 1

� xy

<latexit sha1_base64="oFzHmF6CJilJ4bjZITeKNEAOwmU=">AAACWHicbVHLSgMxFM2MrX34qnXpJli0biwzIuhGKLpxWcE+oFNKJnOnDc1khiQjLUN/UnChv+LG9IHY6oWQw7nnPnLiJ5wp7Tgflr2Ty+8WiqXy3v7B4VHluNpRcSoptGnMY9nziQLOBLQ10xx6iQQS+Ry6/uRxke++glQsFi96lsAgIiPBQkaJNtSwEns+jJjI/Ihoyabzad3z8KzugQh+uPstzZWLL7BjdI653Q3pdrdFsw3BsFJzGs4y8F/grkENraM1rLx5QUzTCISmnCjVd51EDzIiNaMc5mUvVZAQOiEj6BsoSARqkC2NmeNzwwQ4jKU5QuMl+7siI5FSs8g3SrPfWG3nFuR/uX6qw7tBxkSSahB0NShMOdYxXriMAyaBaj4zgFDJzK6YjokkVJu/KBsT3O0n/wWd64Zr8PNNrfmwtqOITtEZukQuukVN9IRaqI0oekdfVs7KW582sgt2aSW1rXXNCdoIu/oN3QK1LQ==</latexit><latexit sha1_base64="oFzHmF6CJilJ4bjZITeKNEAOwmU=">AAACWHicbVHLSgMxFM2MrX34qnXpJli0biwzIuhGKLpxWcE+oFNKJnOnDc1khiQjLUN/UnChv+LG9IHY6oWQw7nnPnLiJ5wp7Tgflr2Ty+8WiqXy3v7B4VHluNpRcSoptGnMY9nziQLOBLQ10xx6iQQS+Ry6/uRxke++glQsFi96lsAgIiPBQkaJNtSwEns+jJjI/Ihoyabzad3z8KzugQh+uPstzZWLL7BjdI653Q3pdrdFsw3BsFJzGs4y8F/grkENraM1rLx5QUzTCISmnCjVd51EDzIiNaMc5mUvVZAQOiEj6BsoSARqkC2NmeNzwwQ4jKU5QuMl+7siI5FSs8g3SrPfWG3nFuR/uX6qw7tBxkSSahB0NShMOdYxXriMAyaBaj4zgFDJzK6YjokkVJu/KBsT3O0n/wWd64Zr8PNNrfmwtqOITtEZukQuukVN9IRaqI0oekdfVs7KW582sgt2aSW1rXXNCdoIu/oN3QK1LQ==</latexit><latexit sha1_base64="oFzHmF6CJilJ4bjZITeKNEAOwmU=">AAACWHicbVHLSgMxFM2MrX34qnXpJli0biwzIuhGKLpxWcE+oFNKJnOnDc1khiQjLUN/UnChv+LG9IHY6oWQw7nnPnLiJ5wp7Tgflr2Ty+8WiqXy3v7B4VHluNpRcSoptGnMY9nziQLOBLQ10xx6iQQS+Ry6/uRxke++glQsFi96lsAgIiPBQkaJNtSwEns+jJjI/Ihoyabzad3z8KzugQh+uPstzZWLL7BjdI653Q3pdrdFsw3BsFJzGs4y8F/grkENraM1rLx5QUzTCISmnCjVd51EDzIiNaMc5mUvVZAQOiEj6BsoSARqkC2NmeNzwwQ4jKU5QuMl+7siI5FSs8g3SrPfWG3nFuR/uX6qw7tBxkSSahB0NShMOdYxXriMAyaBaj4zgFDJzK6YjokkVJu/KBsT3O0n/wWd64Zr8PNNrfmwtqOITtEZukQuukVN9IRaqI0oekdfVs7KW582sgt2aSW1rXXNCdoIu/oN3QK1LQ==</latexit><latexit sha1_base64="oFzHmF6CJilJ4bjZITeKNEAOwmU=">AAACWHicbVHLSgMxFM2MrX34qnXpJli0biwzIuhGKLpxWcE+oFNKJnOnDc1kh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WJBdV+Nt91hs6sM0JhpOyTBs3d3xMZFlqnIrCdApuJXq7l5n+1fmLCaz9jMk4MlWTxUZhwZCKUH45GTFFieGoBE8XsrohMsMLE2HgqNgRv+eRV6FzWPcsPjVrztoijDCdwChfgwRU04R5a0AYCE3iGV3hzhPPivDsfi9aSU8wcwx85nz+neY34</latexit><latexit sha1_base64="xpWqfMGp4qSykFNTx9VbZxi6dgo=">AAAB63icbZDLSgMxFIbP1Futt6pLN8EiuiozUtCNUHTjsoK9QDuUTJppQ5PMkGSEYegruHGhiFtfyJ1vY6adhbb+EPj4zznknD+IOdPGdb+d0tr6xuZWebuys7u3f1A9POroKFGEtknEI9ULsKacSdo2zHDaixXFIuC0G0zv8nr3iSrNIvlo0pj6Ao8lCxnBJrfS85t0WK25dXcutApeATUo1BpWvwajiCSCSkM41rrvubHxM6wMI5zOKoNE0xiTKR7TvkWJBdV+Nt91hs6sM0JhpOyTBs3d3xMZFlqnIrCdApuJXq7l5n+1fmLCaz9jMk4MlWTxUZhwZCKUH45GTFFieGoBE8XsrohMsMLE2HgqNgRv+eRV6FzWPcsPjVrztoijDCdwChfgwRU04R5a0AYCE3iGV3hzhPPivDsfi9aSU8wcwx85nz+neY34</latexit><latexit sha1_base64="xpWqfMGp4qSykFNTx9VbZxi6dgo=">AAAB63icbZDLSgMxFIbP1Futt6pLN8EiuiozUtCNUHTjsoK9QDuUTJppQ5PMkGSEYegruHGhiFtfyJ1vY6adhbb+EPj4zznknD+IOdPGdb+d0tr6xuZWebuys7u3f1A9POroKFGEtknEI9ULsKacSdo2zHDaixXFIuC0G0zv8nr3iSrNIvlo0pj6Ao8lCxnBJrfS85t0WK25dXcutApeATUo1BpWvwajiCSCSkM41rrvubHxM6wMI5zOKoNE0xiTKR7TvkWJBdV+Nt91hs6sM0JhpOyTBs3d3xMZFlqnIrCdApuJXq7l5n+1fmLCaz9jMk4MlWTxUZhwZCKUH45GTFFieGoBE8XsrohMsMLE2HgqNgRv+eRV6FzWPcsPjVrztoijDCdwChfgwRU04R5a0AYCE3iGV3hzhPPivDsfi9aSU8wcwx85nz+neY34</latexit>

Page 16: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 16Ren NgCS184/284A

Shear Matrix

x0 =??

y0 =??

x0

y0

�=

1 a0 1

� xy

<latexit sha1_base64="X7xTdjIFiturU9Y0o8RuD4rXvdI=">AAACV3icbVHLTgIxFO0MiIgv0KWbRqK4IjPGRDcmRDcuMZFHwkxIp1ygodOZtB3DZMJPGjf8ihstjxgBb9L05NxzHz0NYs6Udpy5Zefye4X94kHp8Oj45LRcOWurKJEUWjTikewGRAFnAlqaaQ7dWAIJAw6dYPK8yHfeQSoWiTedxuCHZCTYkFGiDdUvCy+AERNZEBIt2XQ2rXkeTmseiMEv97ilcfE1JkbmmNvdUG43W/TaEPTLVafuLAPvAncNqmgdzX75wxtENAlBaMqJUj3XibWfEakZ5TAreYmCmNAJGUHPQEFCUH629GWGrwwzwMNImiM0XrJ/KzISKpWGgVGa/cZqO7cg/8v1Ej188DMm4kSDoKtBw4RjHeGFyXjAJFDNUwMIlczsiumYSEK1+YqSMcHdfvIuaN/WXYNf76qNp7UdRXSBLtENctE9aqAX1EQtRNEn+rJyVt6aW992wS6upLa1rjlHG2FXfgDNkLYm</latexit><latexit sha1_base64="X7xTdjIFiturU9Y0o8RuD4rXvdI=">AAACV3icbVHLTgIxFO0MiIgv0KWbRqK4IjPGRDcmRDcuMZFHwkxIp1ygodOZtB3DZMJPGjf8ihstjxgBb9L05NxzHz0NYs6Udpy5Zefye4X94kHp8Oj45LRcOWurKJEUWjTikewGRAFnAlqaaQ7dWAIJAw6dYPK8yHfeQSoWiTedxuCHZCTYkFGiDdUvCy+AERNZEBIt2XQ2rXkeTmseiMEv97ilcfE1JkbmmNvdUG43W/TaEPTLVafuLAPvAncNqmgdzX75wxtENAlBaMqJ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mCmNAJGUHPQEFCUH629GWGrwwzwMNImiM0XrJ/KzISKpWGgVGa/cZqO7cg/8v1Ej188DMm4kSDoKtBw4RjHeGFyXjAJFDNUwMIlczsiumYSEK1+YqSMcHdfvIuaN/WXYNf76qNp7UdRXSBLtENctE9aqAX1EQtRNEn+rJyVt6aW992wS6upLa1rjlHG2FXfgDNkLYm</latexit>

Horizontal shift is 0 at y=0Horizontal shift is a at y=1

Hints:

a

1

Vertical shift is always 0

Page 17: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 17Ren NgCS184/284A

Rotate

R45

(about the origin (0, 0), CCW by default)

Page 18: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 18Ren NgCS184/284A

Rotation Matrix

Lecture 3 Math

x0 � x1 � x2 � x3 � y

x+ y � ✓

f(x)

f(x+ y) = f(x) + f(y)

f(ax) = af(x)

f(x) = af(x)

Scale:Sa(x) = ax

S2(x)� S2(x1)� S2(x2)� S2(x3 � S2(ax)� aS2(x)� S2(x)� S2(y)� S2(x+ y)

S2(x) = 2x

aS2(x) = 2ax

S2(ax) = 2ax

S2(ax) = aS2(x)

S2(x+ y) = 2(x+ y)

S2(x) + S2(y) = 2x+ 2y

S2(x+ y) = S2(x) + S2(y)

Rotations:

R✓(x)�R✓(x0)�R✓(x1)�R✓(x2)�R✓(x3)�R✓(ax)� aR✓(x)�R✓(y)�R✓(x+ y)

Translation:Ta,b(x0)� Ta,b(x1)� Ta,b(x2)� Ta,b(x3)

Lecture 3 Math

x0 � x1 � x2 � x3 � y

x+ y � ✓ � xx � xy

cos ✓ � sin ✓

f(x)

f(x+ y) = f(x) + f(y)

f(ax) = af(x)

f(x) = af(x)

Scale:Sa(x) = ax

S2(x)� S2(x1)� S2(x2)� S2(x3 � S2(ax)� aS2(x)� S2(x)� S2(y)� S2(x+ y)

S2(x) = 2x

aS2(x) = 2ax

S2(ax) = 2ax

S2(ax) = aS2(x)

S2(x+ y) = 2(x+ y)

S2(x) + S2(y) = 2x+ 2y

S2(x+ y) = S2(x) + S2(y)

Ss =

sx 00 sy

Ss =

0.5 00 2

s =⇥0.5 2

⇤T

Ssx0 � Ssx1 � Ssx2 � Ssx3

Lecture 3 Math

x0 � x1 � x2 � x3 � y

x+ y � ✓ � xx � xy

cos ✓ � sin ✓

f(x)

f(x+ y) = f(x) + f(y)

f(ax) = af(x)

f(x) = af(x)

Scale:Sa(x) = ax

S2(x)� S2(x1)� S2(x2)� S2(x3 � S2(ax)� aS2(x)� S2(x)� S2(y)� S2(x+ y)

S2(x) = 2x

aS2(x) = 2ax

S2(ax) = 2ax

S2(ax) = aS2(x)

S2(x+ y) = 2(x+ y)

S2(x) + S2(y) = 2x+ 2y

S2(x+ y) = S2(x) + S2(y)

Ss =

sx 00 sy

Ss =

0.5 00 2

s =⇥0.5 2

⇤T

Ssx0 � Ssx1 � Ssx2 � Ssx3

Lecture 3 Math

x0 � x1 � x2 � x3 � y

x+ y � ✓ � xx � xy

cos ✓ � sin ✓

f(x)

f(x+ y) = f(x) + f(y)

f(ax) = af(x)

f(x) = af(x)

Scale:Sa(x) = ax

S2(x)� S2(x1)� S2(x2)� S2(x3 � S2(ax)� aS2(x)� S2(x)� S2(y)� S2(x+ y)

S2(x) = 2x

aS2(x) = 2ax

S2(ax) = 2ax

S2(ax) = aS2(x)

S2(x+ y) = 2(x+ y)

S2(x) + S2(y) = 2x+ 2y

S2(x+ y) = S2(x) + S2(y)

Ss =

sx 00 sy

Ss =

0.5 00 2

s =⇥0.5 2

⇤T

Ssx0 � Ssx1 � Ssx2 � Ssx3

Lecture 3 Math

x0 � x1 � x2 � x3 � y

x+ y � ✓ � xx � xy

cos ✓ � sin ✓

f(x)

f(x+ y) = f(x) + f(y)

f(ax) = af(x)

f(x) = af(x)

Scale:Sa(x) = ax

S2(x)� S2(x1)� S2(x2)� S2(x3 � S2(ax)� aS2(x)� S2(x)� S2(y)� S2(x+ y)

S2(x) = 2x

aS2(x) = 2ax

S2(ax) = 2ax

S2(ax) = aS2(x)

S2(x+ y) = 2(x+ y)

S2(x) + S2(y) = 2x+ 2y

S2(x+ y) = S2(x) + S2(y)

Ss =

sx 00 sy

Ss =

0.5 00 2

s =⇥0.5 2

⇤T

Ssx0 � Ssx1 � Ssx2 � Ssx3

Rotations:

R✓(x)�R✓(x0)�R✓(x1)�R✓(x2)�R✓(x3)�R✓(ax)� aR✓(x)�R✓(y)�R✓(x+ y)

R✓ =

cos ✓ � sin ✓sin ✓ cos ✓

Translation:Tb(x) = x+ b

Tb(x0)� Tb(x1)� Tb(x2)� Tb(x3)� Tb(x)� Tb(y)� Tb(x+ y)� Tb(x) + Tb(y)

Ta,b(x0)� Ta,b(x1)� Ta,b(x2)� Ta,b(x3)� Ta,b(x)� Ta,b(y)� Ta,b(x+ y)� Ta,b(x) + Ta,b(y)

Reflection:Rey(x0)�Rey(x1)�Rey(x2)�Rey(x3)

Rex(x0)�Rex(x1)�Rex(x2)�Rex(x3)

Shear:Hx(x0)�Hx(x1)�Hx(x2)�Hx(x3)

Misc:f(x0)� f(x1)� f(x2)� f(x3)

f(x) = T3,1(S0.5(x))��f(x) = S0.5(T3,1(x))

f(x) = g(x) + b

Euclidean:|f(x)� f(y)| = |x� y|

2

Page 19: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 19Ren NgCS184/284A

Linear Transforms = Matrices

x0 = a x+ b y

y0 = c x+ d y

x0

y0

�=

a bc d

� xy

x0 = M x

(of the same dimension)

Page 20: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

Questions?

Page 21: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Today

• Why study transformation

• 2D transformations

• Homogeneous coordinates

- Why homogeneous coordinates

- Affine transformation

21

Page 22: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 22Ren NgCS184/284A

Translate

T1,1Ttx,ty

Page 23: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 23Ren NgCS184/284A

Translation??

T1,1

x0 = x+ tx

y0 = y + ty

Ttx,ty

Page 24: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

Why Homogeneous Coordinates

• Translation cannot be represented in matrix form

24

x0

y0

�=

a bc d

� xy

�+

txty

<latexit sha1_base64="N69qeTDb59xHCbfPH0Qfs7gRUbs=">AAACfXicbZFdS8MwFIbT+j2/pl56Exx+y2hF0BtB9MZLBafCOkqans2wNC3JqTjK/oW/zDv/ijeaziGueiDk5T1PkpNzokwKg5737rhT0zOzc/MLtcWl5ZXV+tr6vUlzzaHFU5nqx4gZkEJBCwVKeMw0sCSS8BD1r8r8wzNoI1J1h4MMOgnrKdEVnKG1wvprEEFPqCJKGGrxMnzZDQI62A1AxT/eeYVhdIdGFuN2jyfI6mXlXRPAYYXAsGQwnKTCesNreqOgf4U/Fg0yjpuw/hbEKc8TUMglM6btexl2CqZRcAnDWpAbyBjvsx60rVQsAdMpRt0b0m3rxLSbarsU0p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b0m3rxLSbarsU0pH7+0TBEmMGSWRJW9+TqeZK879cO8fuWacQKssRFP9+qJtLiiktR0FjoYGjHFjBuBa2VsqfmGYc7cBqtgl+9ct/xf1x07f69qRxcTluxzzZJFtkj/jklFyQa3JDWoSTD4c6+86B8+luu0du8xt1nfGZDTIR7ukX89XFpw==</latexit><latexit sha1_base64="N69qeTDb59xHCbfPH0Qfs7gRUbs=">AAACfXicbZFdS8MwFIbT+j2/pl56Exx+y2hF0BtB9MZLBafCOkqans2wNC3JqTjK/oW/zDv/ijeaziGueiDk5T1PkpNzokwKg5737rhT0zOzc/MLtcWl5ZXV+tr6vUlzzaHFU5nqx4gZkEJBCwVKeMw0sCSS8BD1r8r8wzNoI1J1h4MMOgnrKdEVnKG1wvprEEFPqCJKGGrxMnzZDQI62A1AxT/eeYVhdIdGFuN2jyfI6mXlXRPAYYXAsGQwnKTCesNreqOgf4U/Fg0yjpuw/hbEKc8TUMglM6btexl2CqZRcAnDWpAbyBjvsx60rVQsAdMpRt0b0m3rxLSbarsU0pH7+0TBEmMGSWRJW9+TqeZK879cO8fuWacQKssRFP9+qJtLiiktR0FjoYGjHFjBuBa2VsqfmGYc7cBqtgl+9ct/xf1x07f69qRxcTluxzzZJFtkj/jklFyQa3JDWoSTD4c6+86B8+luu0du8xt1nfGZDTIR7ukX89XFpw==</latexit>

(So, translation is NOT linear transform!)

• But we don’t want translation to be a special case

• Is there a unified way to represent all transformations?(and what’s the cost?)

Page 25: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 25Ren NgCS184/284A

Solution: Homogenous Coordinates

Add a third coordinate (w-coordinate)

• 2D point = (x, y, 1)T

• 2D vector = (x, y, 0)T

Matrix representation of translations�

⇤x�

y�

w�

⌅ =

⇤1 0 tx0 1 ty0 0 1

⌅ ·

⇤xy1

⌅ =

⇤x + txy + ty

1

What if you translate a vector?

Page 26: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 26Ren NgCS184/284A

Homogenous Coordinates

Valid operation if w-coordinate of result is 1 or 0

• vector + vector = vector

• point – point = vector

• point + vector = point

• point + point = ??

In homogeneous coordinates, 0

@xyw

1

A is the 2D point

0

@x/wy/w1

1

A , w 6= 0

<latexit sha1_base64="UNbgyt1NYV57oB/KINo7BMhsFUA=">AAACdXicbVFNT9tAEF0baKlb2pReKlVIA4GqBxRsFAmOqO2hRyoRQMpG0XozSVas1+7uGIis/AN+XW/9G7302nViVeVjpF09vTffkxZaOYrjX0G4srr27Pn6i+jlq43Xb1pvN89dXlqJPZnr3F6mwqFWBnukSONlYVFkqcaL9OpLrV9co3UqN2c0K3CQiYlRYyUFeWrYuuMpTpSpikyQVbdziABugXOY1d9NxNGM/okRB+7h1GaVchxoihwOv3IocmVo7sWnch3AzTJfA5L7Ofd5TRv8AXE0bLXjTrwweAySBrRZY6fD1k8+ymWZoSGphXP9JC5oUAlLSmr0/ZYOCyGvxAT7HhqRoRtUi63NYc8zIxjn1j9DsGD/j6hE5twsS71nPbR7qNXkU1q/pPHxoFKmKAmNXBYalxooh/oEMFIWJemZB0Ja5XsFORVWSPKHqpeQPBz5MTg/7CTdTvd7t33yuVnHOvvAdtgnlrAjdsK+sVPWY5L9Dt4H28FO8CfcCnfDj0vXMGhi3rF7Fh78BQRTunQ=</latexit>

Page 27: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 27Ren NgCS184/284A

Affine Transformations

Affine map = linear map + translation

Using homogenous coordinates:�

⇤x�

y�

1

⌅ =

⇤a b txc d ty0 0 1

⌅ ·

⇤xy1

�x�

y�

⇥=

�a bc d

⇥·�

xy

⇥+

�txty

Page 28: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 28Ren NgCS184/284A

2D Transformations

Scale

Rotation

Translation

T(tx, ty) =

⇤1 0 tx0 1 ty0 0 1

S(sx, sy) =

⇤sx 0 00 sy 00 0 1

R(�) =

⇤cos � � sin � 0sin� cos � 0

0 0 1

Page 29: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 29Ren NgCS184/284A

Inverse Transform

is the inverse of transform in both a matrix and geometric sense

M�1

M�1

M

M�1 M�1

Page 30: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 30

Composing Transforms

Page 31: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 31Ren NgCS184/284A

Composite Transform

?

Page 32: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 32Ren NgCS184/284A

Translate Then Rotate?

M = R45 · T(1,0) M = R45 · T(1,0)

Page 33: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 33Ren NgCS184/284A

Rotate Then Translate

M = T(1,0) ·R45 M = T(1,0) ·R45

Page 34: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 34Ren NgCS184/284A

Transform Ordering Matters!

M = R45 · T(1,0) M = R45 · T(1,0)

M = T(1,0) ·R45 M = T(1,0) ·R45

Page 35: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 35 Ren NgCS184/284A

Transform Ordering Matters!

Matrix multiplication is not commutative

M = R45 · T(1,0)M = T(1,0) ·R45≠

2

4cos 45� � sin 45� 0sin 45� cos 45� 0

0 0 1

3

5

2

41 0 10 1 00 0 1

3

5 6=

2

41 0 10 1 00 0 1

3

5

2

4cos 45� � sin 45� 0sin 45� cos 45� 0

0 0 1

3

5

Recall the matrix math represented by these symbols:

Note that matrices are applied right to left:

T(1,0) ·R45

2

4xy1

3

5 =

2

41 0 10 1 00 0 1

3

5

2

4cos 45� � sin 45� 0sin 45� cos 45� 0

0 0 1

3

5

2

4xy1

3

5

Ren NgCS184/284A

Transform Ordering Matters!

Matrix multiplication is not commutative

M = R45 · T(1,0)M = T(1,0) ·R45≠

2

4cos 45� � sin 45� 0sin 45� cos 45� 0

0 0 1

3

5

2

41 0 10 1 00 0 1

3

5 6=

2

41 0 10 1 00 0 1

3

5

2

4cos 45� � sin 45� 0sin 45� cos 45� 0

0 0 1

3

5

Recall the matrix math represented by these symbols:

Note that matrices are applied right to left:

T(1,0) ·R45

2

4xy1

3

5 =

2

41 0 10 1 00 0 1

3

5

2

4cos 45� � sin 45� 0sin 45� cos 45� 0

0 0 1

3

5

2

4xy1

3

5

Page 36: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 36Ren NgCS184/284A

Composing Transforms

Sequence of affine transforms A1, A2, A3, ...

• Compose by matrix multiplication

• Very important for performance!

An(. . . A2(A1(x))) = An · · · A2 · A1 ·

⇤xy1

Pre-multiply n matrices to obtain a single matrix representing combined transform

Page 37: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 37Ren NgCS184/284A

Decomposing Complex Transforms

How to rotate around a given point c? 1. Translate center to origin 2. Rotate 3. Translate back

Matrix representation?

T(�c) T(c)R(�)

T(c) · R(�) · T(�c)

Page 38: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara

3D Transforms

38

Page 39: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 39 Ren NgCS184/284A

3D Transformations

Use homogeneous coordinates again:

• 3D point = (x, y, z, 1)T

• 3D vector = (x, y, z, 0)T

Use 4×4 matrices for affine transformations�

⇧⇧⇤

x�

y�

z�

1

⌃⌃⌅ =

⇧⇧⇤

a b c txd e f tyg h i tz0 0 0 1

⌃⌃⌅ ·

⇧⇧⇤

xyz1

⌃⌃⌅

In general, (x, y, z, w) (w != 0) is the 3D point:

(x/w, y/w, z/w)

Page 40: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

GAMES101 Lingqi Yan, UC Santa Barbara 40

Ren NgCS184/284A

3D Transformations

Use homogeneous coordinates again:

• 3D point = (x, y, z, 1)T

• 3D vector = (x, y, z, 0)T

Use 4×4 matrices for affine transformations�

⇧⇧⇤

x�

y�

z�

1

⌃⌃⌅ =

⇧⇧⇤

a b c txd e f tyg h i tz0 0 0 1

⌃⌃⌅ ·

⇧⇧⇤

xyz1

⌃⌃⌅

Ren NgCS184/284A

3D Transformations

Use homogeneous coordinates again:

• 3D point = (x, y, z, 1)T

• 3D vector = (x, y, z, 0)T

Use 4×4 matrices for affine transformations�

⇧⇧⇤

x�

y�

z�

1

⌃⌃⌅ =

⇧⇧⇤

a b c txd e f tyg h i tz0 0 0 1

⌃⌃⌅ ·

⇧⇧⇤

xyz1

⌃⌃⌅What’s the order? Linear Transform first or Translation first?

Page 41: Introduction to Computer Graphics - UCSB · GAMES101 Lingqi Yan, UC Santa Barbara Last Lecture • Vectors-Basic operations: addition, multiplication • Dot Product-Forward / backward

Thank you!(And thank Prof. Ravi Ramamoorthi and Prof. Ren Ng for many of the slides!)