Transformations We want to be able to make changes to the image larger/smaller rotate move This can...

84
Transformations We want to be able to make changes to the image • larger/smaller • rotate • move This can be efficiently achieved through mathematical operations known as transformations

Transcript of Transformations We want to be able to make changes to the image larger/smaller rotate move This can...

Page 1: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Transformations

• We want to be able to make changes to the image• larger/smaller

• rotate

• move

• This can be efficiently achieved through mathematical operations known as transformations

Page 2: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Transformations

• We will transform the endpoints only• If we then draw the (new) lines between the

transformed endpoints, we get the transformed image• This only works for certain types of transformations

known as affine transformations• Such transformations preserve lines and distances and relative

proportions• i.e., points on the same line before remain on the same line after

an affine transformation

Page 3: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Transformations

• Three transformations that fall into this category are• Scaling• Rotation• Translation

Page 4: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

But First…

• We’re going to need a bit of math…

• … just enough to get the general idea

Page 5: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Matrices

• Matrix• 2 dimensional array (of numbers)• m x n matrix

• m rows

• n columns

Page 6: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Matrices

• Matrix• 2 dimensional array (of numbers)• m x n matrix

• m rows

• n columns

• xij is the entry at row I, column j

232221

131211

xxx

xxx2 rows

3 columns

Page 7: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• 1 x 2 matrix

• 2 x 2 matrix

• a 2 x 1 matrix

• A 3 x 3 matrix

Some Examples

51

10

01

987

654

321

7

3

Page 8: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Matrix Multiplication

• In matrix multiplication, elements in the result matrix are obtained by taking the sums of the products of the elements of a row of the first with a column of the second

• Calculating the sum of products of the ith row with the jth column produces the element at location [i][j]

22121211211211112221

12111211 yxyxyxyx

yy

yyxx

Page 9: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

22121211211211112221

12111211 yxyxyxyx

yy

yyxx

22121211211211112221

12111211 yxyxyxyx

yy

yyxx

Matrix Multiplication

Page 10: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• In order to calculate a sum of products, the length of a row of the first matrix must be equal to the length of a column in the second matrix• length of a row = # columns

• length of a column = # rows

Matrix Multiplication

.........

.........

.........131211 xxx

3 columns

row

............

............

............

31

21

11

y

y

y

3 rows

column

Page 11: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Matrix Multiplication

• Can therefore only multiply m x k matrix with a k x n matrix • # of columns of first operand = # rows of second operand

• Results in an m x n matrix

34333231

24232221

14131211

24232221

14131211

3231

2221

2111

zzzz

zzzz

zzzz

yyyy

yyyy

xx

xx

xx

3 rows

2 rows

2 columns 4 columns

3 ro

ws

4 columns

Page 12: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

34333231

24232221

14131211

24232221

14131211

3231

2121

1211

zzzz

zzzz

zzzz

yyyy

yyyy

zx

xx

xx

____

____

___11

8765

4321

65

43

21

Page 13: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(1 1) + (2 5) = 1 + 10 = 11

____

____

___11

8765

4321

65

43

21

Page 14: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(1 2) + (2 6) = 2 + 12 = 14

____

____

__1411

8765

4321

65

43

21

Page 15: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(1 3) + (2 7) = 3 + 14 = 17

____

____

_171411

8765

4321

65

43

21

Page 16: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(1 4) + (2 8) = 4 + 16 = 20

____

____

20171411

8765

4321

65

43

21

Page 17: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(3 1) + (4 5) = 3 + 20 = 23

____

___23

20171411

8765

4321

65

43

21

Page 18: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(3 2) + (4 6) = 6 + 24 = 30

____

__3023

20171411

8765

4321

65

43

21

Page 19: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(3 3) + (4 7) = 9 + 28 = 37

____

_373023

20171411

8765

4321

65

43

21

Page 20: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(3 4) + (4 8) = 12 + 32 = 44

____

44373023

20171411

8765

4321

65

43

21

Page 21: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(5 1) + (6 5) = 5 + 30 = 35

___35

44373023

20171411

8765

4321

65

43

21

Page 22: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(5 2) + (6 6) = 10 + 36 = 46

__4635

44373023

20171411

8765

4321

65

43

21

Page 23: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(5 3) + (6 7) = 15 + 42 = 57

_574635

44373023

20171411

8765

4321

65

43

21

Page 24: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Example

(5 4) + (6 8) = 20 + 48 = 68

68574635

44373023

20171411

8765

4321

65

43

21

Page 25: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

The Algorithm

multiply(a, b) // a = M x K b = K x Nresult = new Matrix(m, n)for i = 1, M // M rows in a

for j = 1, N // N columns in bresult[i][j] = 0for k = 1, K // K columns in a, rows in b

result[i][j] += a[i, k] * b[k, j]return result

Page 26: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

What’s this got to do with us?

• Matrices are a convenient and powerful way of expressing transformations

• Allows complex sequences of complex transformations to be easily expressed and calculated

• Let’s look at one simple transformation and see how

Page 27: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Scaling

• Transformation that enlarges or reduces image

Page 28: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Scaling

• Scaling can be done in the x-coordinate …

Page 29: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Scaling

• … in the y-coordinate …

Page 30: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Scaling

• … or in both …

Page 31: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Scaling

• We could simply say that • To scale in the x-coordinate, multiply by the

scaling factor• that is, to scale to double the size in the x-

coordinate, simply multiply the x-coordinate of all endpoints by 2

• Similarly to reduce the size

• Similarly in the y-direction

Page 32: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Simple enough

• The above works and is totally adequate to scale

• Why complicate matters?

• Why even consider doing anything else?

Page 33: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Multiple Transformations

• Will want to • scale and rotate

• translate, rotate and translate again

• etc,…

• Don’t want to have to apply each transformation individually

Page 34: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• Let’s represent a point as a 1 x 2 matrix

• We often call a 1 x n matrix a vector

• Let’s reexamine multiplying this vector with a 2 x 2 matrix

Using Matrices

yx

Page 35: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

dybxcyaxdc

bayx

Applying Matrix Multiplication

• We can think of the above multiplication taking the point (x, y) and producing a new point (x', y') where • x' = ax + cy• y' = bx + dy

yxdc

bayx

Page 36: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Transformation Matrix

• We see that when a 2 x 2 matrix • is multiplied with a 1 x 2 vector representing a point …

• … a new 1 x 2 vector is produced …

• … that can be though of as representing a new point

• We thus call the 2 x 2 matrix a transformation matrix• The matrix when applied to the original point transforms it

into the new point

Page 37: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Where Matrix Multiplication Comes In

• Looking at the above we can get a sense of how the 2 x 2 matrix transforms the point:

dybxcyaxdc

bayx

dc

baa: the effect of the original x-value on the new x-value

c: the effect of the original y-value on the new x-value

b: the effect of the original x-value on the new y-value

d: the effect of the original y-value on the new y-value

x' y'

Page 38: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

An Trivial Example

• Following this line of thought, the matrix:

10

01a: the original x-value has an identity effect on the new x-valuec: the original y-value has no effect on new x-value

b: the original x-value has no effect on the new y-value

d: the original y-value has an identity effect on the new y-value

should transform the original point back to itself

Page 39: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

A Trivial Example

• To see that this is so:

yxyxyxyx 100110

01

• The matrix

is called the identity matrix

10

01

Page 40: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Applying this to Scaling

• Using this approach, let’s try to produce some transformation matrices for scaling• Let’s first scale the x-coordinate alone

• We’d like • the new (transformed) x-value

• to be a factor of the original x-value

• not be affected by the original y-value

• the new (transformed) y-value

• to be identical to the original x-value

• (not be affected by the original x-value)

Page 41: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Doubling the Size in the x-Direction

• As an example, to double the x-value• We’d like

• the new (transformed) x-value • to be 2 times the original x-value

• not be affected by the original y-value

• the new (transformed) y-value • to be identical to the original x-value

• (not be affected by the original x-value)

Page 42: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

The Effect of the Transformation Matrix

• By recalling how the transformation matrix affects the original point, we can come up with the following ‘educated’ guess

10

02a: the effect of the original x-value on the new x-value

c: the effect of the original y-value on the new x-value

b: the effect of the original x-value on the new y-value

d: the effect of the original y-value on the new y-value

Page 43: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

yxyxyxyx 2100210

02

Checking Our Guess

• So we see indeed, our hunch was correct!

• Doing the multiplication produces

Page 44: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Other Scaling Matrices

• The same line of reasoning produces• The general transformation matrix for scaling in the x-

direction alone

• The general transformation matrix for scaling in the y-direction alone

• The general transformation matrix for scaling in both directions

10

0xS

yS0

01

y

x

S

S

0

0 For practice, verify these by doing the matrix multiplications!!

Page 45: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Applying Multiple Transformations

• If we multiply the ‘scale x’ matrix and the ‘scale y’ matrix, we obtain the scale matrix for both

y

x

y

x

S

S

S

S

0

0

0

01

10

0

Page 46: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Applying Multiple Transformations

• Similarly, if we multiply the ‘double size’ matrix and the ‘half size’ matrix, we obtain the identity matrix

10

01

5.00

05.0

20

02

Page 47: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• Although we won’t prove it, it can be shown that multiplying two transformation matrices produces a transformation matrix whose effect is the first transformation followed by the second!

• This result extends to three or more as well

Applying Multiple Transformations

Page 48: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• This is a valuable result because it means we can achieve the effect of several transformation by applying a single matrix to our image rather than having to perform a sequence of transforms.

Applying Multiple Transformations

Page 49: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Rotations About the Origin

• The next transformation involves rotating the endpoints (and therefore the line) about the point (0, 0)

Page 50: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Rotations About the Origin

• Again, we will try to derive the transformation matrix

• This one is a bit more involved and requires some trigonometry and geometry

Page 51: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• We view the point (x, y) as the endpoint of a line segment whose other end is the origin

• The line segment forms some angle-- call it θ -- with the x-axis

θ

(x, y)

(0, 0)

y axis

x axis

Rotations About the Origin

Page 52: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• the rotation involves rotating the endpoint (x, y) around the origin to a new point (x', y').

• the other endpoint remains the origin,

• the length of the line remains the same.

Rotation About the Origin

y axis

x axisO

A

B

OBOA

(x, y)

(x', y')

Page 53: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Rotation About the Origin

• We’d like to define the value of the new (transformed) point (x',y') in terms of the original point(x, y)

• If we can do that, we can come up with a transformation matrix!

• And, again, as we said before, this will require a bit of math

Page 54: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

θ

y axis

x axis

Rotation About the Origin

• we can think of the rotation as ‘increasing’ the original angle of the line, θ, by an additional amount,

(x', y')

(x, y)

Page 55: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

The Sum of Two Angles

• Given two angles and :

sin( + ) = cos sin + sin cos

cos( + ) = cos cos - sin sin

• We’re not going to derive these formulae

Page 56: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

• For right triangles

• sine = opposite / hypotenuse

• cosine = opposite / hypotenuse

• tangent = opposite / adjacent (we won’t be using this)

Remember SOHCAHTOA?

θ

θ

θ

Page 57: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

θ

y axis

x axis

Rotation About the Origin

(x1, y1)

y1

x1

L

L

y1sin or,

Ly sin1

sine = opposite / hypotenuse

Page 58: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

θ

y axis

x axis

Rotation About the Origin

(x1, y1)

y1

x1

L

L

x1cos

Lx cos1

or,

cosine = adjacent / hypotenuse

Page 59: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

θ

y axis

x axis

Rotation About the Origin

(x2, y2)

(x1, y1)

• Recall, the length of the line, L, stays the same

• The angle of the line ending at (x2y2) is θ+

L

L

Page 60: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

L

y2)sin(

θ

y axis

x axis

Rotation About the Origin

(x2, y2)

(x1, y1)L

y2

cossinsincos)sin(

and we stated before that:

From the diagram:

so…

Page 61: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

And since

Through the Magic of Algebraic Manipulation

LLyL

y cossinsincoscossinsincos 22

Ly sin1

Lx cos1

We get

112 sincos xyy

We have defined y2 in terms of x1 and y1– exactly what we were looking for!!!

Page 62: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

L

x2)cos(

θ

y axis

x axis

Rotation About the Origin

(x2, y2)

(x1, y1)L

x2

sinsincoscos)cos(

and:

Similarly, from the diagram:

so…

Page 63: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

LLxL

x sinsincoscossinsincoscos 22

More Magic of Algebraic Manipulation

And again, since

Ly sin1

Lx cos1

We get

112 sincos yxx

We have similarly defined x2 in terms of x1 and y1– again exactly what we were looking for!!!

Page 64: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

A Rotation-Around-the-Origin Matrix

• Given

112 sincos yxx 112 sincos xyy and

we can clearly see the effects of x1 and y1 on x2 and y2

• x1 affects x2 via cos

• x1 affects y2 via sin

• y1 affects x2 via -sin

• y1 affects y2 via cos

Page 65: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

A Rotation Around the Origin Matrix

• This results in the transformation matrix for a rotation about the origin of angle

cossin

sincos

the effect of the original x-value on the new x-value

the effect of the original y-value on the new x-value

the effect of the original x-value on the new y-value

the effect of the original y-value on the new y-value

Page 66: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Translation

• Moving the image a fixed amount in either• the x-direction

• x2 = x1 + Tx Tx is the fixed amount to move in the x-direction

• the y-direction• y2 = y1 + Ty Ty is the fixed amount to move in the y-direction

• both

Page 67: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Translation

• Sounds easy• add the x translation amount to the x coordinate• add the y translation amount to the y coordinate

• But we’d like to have a matrix• Would like to combine our various

transformations• OTOH, is that really all that important?

Page 68: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Rotation About an Arbitrary Point

• We’d like to rotate around points other than the origin

Page 69: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Rotation About an Arbitrary Point

• We can accomplish this by• Translating the desired rotation point to the origin…

Page 70: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Rotation About an Arbitrary Point

• …rotating about the origin…

Page 71: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Rotation About an Arbitrary Point

• …translating back to the original point…

Page 72: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

The Problem

• Our transformation matrices till now had entries for• How the old x affects the new x and y• How the old y affects the new x and y

dc

baa: the effect of the original x-value on the new x-value

c: the effect of the original y-value on the new x-value

b: the effect of the original x-value on the new y-value

d: the effect of the original y-value on the new y-value

Page 73: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

The Problem

• In a translation, the changes are fixed• independent of the original x and y values

• Where would they go in the matrix?

Page 74: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Homogeneous Coordinates

• An approach to incorporating a fixed translation into a transformation matrix

• Using homogeneous coordinates involves…

Page 75: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Homogeneous Coordinates

• Using a 3 x 3 transformation matrix rather than a 2 x 2…• For example, our scaling matrix becomes

• Not too bad– the extra row/column looks like an identity matrix• The 0’s and 1 shouldn’t make the sums of products much harder to do

• Similarly for the rotation matrix

100

00

00

x

x

S

S

Page 76: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Homogeneous Coordinates

• The introduction of an additional ‘dummy’ coordinate, w• Points are now specified by a 1 x 3 vector

• We can always get x and y back again by dividing by w

• And in any event, don’t get too worried, we’re going to keep w = 1

wywxw

Page 77: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Homogeneous Coordinates

• Let’s just see the effect of all this• As an example, we’ll do a scaling

• Which is the correct representation under homogeneous coordinates for the new (scaled) point

• … And similarly for rotation• You can do the math if you want

wywSxwSS

S

wywxw yxy

x

100

00

00

Page 78: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

1

010

001

yx TT

A Translation Matrix

• Let’s try to understand this matrix• The original x and y have an identity effect (the shaded 2 x 2 matrix

is the identity matrix) on the new points• The Tx and Ty will be multiplied by w (if you can’t visualize this,

you’ll see it on the next slide) and added into the sum of products• Dividing the result by w would then produce the fixed translation value• To see this, let’s do the math

Page 79: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

wwTywwTxw

TT

wywxw yx

yx

1

010

001

A Translation Matrix

• And again, this is the desired point• modulo the division by w

Page 80: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Revisiting Rotation about an Arbitrary Point

• Given • a rotation point of (xc, yc)

• A rotation angle of

(xc, yc)

(x, y)

Page 81: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Revisiting Rotation about an Arbitrary Point

• We first translate (xc, yc) to the origin

• Translation matrix(xc, yc)

1

010

001

cc yx

Page 82: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Revisiting Rotation about an Arbitrary Point

• We then perform the rotation (around the origin) of angle …

• Rotation matrix

100

0cossin

0sincos

Page 83: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

Revisiting Rotation about an Arbitrary Point

• And finish off with a translation back to (xc, yc)

• Translation matrix (xc, yc)

(x, y)

1

010

001

cc yx

Page 84: Transformations We want to be able to make changes to the image larger/smaller rotate move This can be efficiently achieved through mathematical operations.

A Matrix for Rotation about an Arbitrary Point

• Putting it all together, gives us

and performing the multiplications produces

1

010

001

100

0cossin

0sincos

1

010

001

cccc yxyx

1cossinsincos

0cossin

0sincos

cccccc yyxxyx