99
ECM2410: Graphics and Animation Transformations Part I Transformations 1/15

Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

ECM2410: Graphics and Animation

Transformations

Part I

Transformations 1/15

Page 2: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems

The reason

Vectors and matrices

The maths

Homogeneous coordinates

A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 3: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems

The reason

Vectors and matrices

The maths

Homogeneous coordinates

A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 4: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices

The maths

Homogeneous coordinates

A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 5: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices

The maths

Homogeneous coordinates

A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 6: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates

A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 7: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates

A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 8: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 9: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D

The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 10: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 11: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D The API

Clocks

An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 12: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D The API

Clocks An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 13: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D The API

Clocks An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 14: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D The API

Clocks An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 15: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Transformations

Coordinate systems The reason

Vectors and matrices The maths

Homogeneous coordinates A trick

Java2D The API

Clocks An example

ReferencesHearn & Baker, Computer Graphics, Chapter 5.Foley et al, Computer Graphics, Chapter 5.

Introduction Transformations 2/15

Page 16: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 17: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 18: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 19: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 20: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 21: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 22: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 23: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinate Systems

User space

Device space

User space (world coordinates)Space in which parts of scene are modelledMoveable: location set with affineTransform class.

Device space (screen coordinates)Coordinates in which picture is renderedSize set with java.awt.setSize()

Introduction Transformations 3/15

Page 24: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Building Complex Objects

Device Coordinates

Construct complex objects from simpler ones, each havingits own local coordinate system.

Transform objects into place.

Introduction Transformations 4/15

Page 25: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Building Complex Objects

Device Coordinates

Construct complex objects from simpler ones, each havingits own local coordinate system.

Transform objects into place.

Introduction Transformations 4/15

Page 26: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Building Complex Objects

Device Coordinates

Construct complex objects from simpler ones, each havingits own local coordinate system.

Transform objects into place.

Introduction Transformations 4/15

Page 27: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Building Complex Objects

Device Coordinates

Construct complex objects from simpler ones, each havingits own local coordinate system.

Transform objects into place.

Introduction Transformations 4/15

Page 28: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinates and Points

Cartesian Coordinates

(3,2)

3

2

(0,0)

a

a =

(32

)

The Point class represents a 2-dimensional point or vector:

a = new Point2D.Double(3.0, 2.0);double ax = a.getX(); // 3.0double ay = a.getY(); // 2.0

Introduction Transformations 5/15

Page 29: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinates and Points

Cartesian Coordinates

(3,2)

3

2

(0,0)

a

a =

(32

)

The Point class represents a 2-dimensional point or vector:

a = new Point2D.Double(3.0, 2.0);double ax = a.getX(); // 3.0double ay = a.getY(); // 2.0

Introduction Transformations 5/15

Page 30: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinates and Points

Cartesian Coordinates

(3,2)

3

2

(0,0)

aa =

(32

)

The Point class represents a 2-dimensional point or vector:

a = new Point2D.Double(3.0, 2.0);double ax = a.getX(); // 3.0double ay = a.getY(); // 2.0

Introduction Transformations 5/15

Page 31: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinates and Points

Cartesian Coordinates

(3,2)

3

2

(0,0)

aa =

(32

)

The Point class represents a 2-dimensional point or vector:

a = new Point2D.Double(3.0, 2.0);double ax = a.getX(); // 3.0double ay = a.getY(); // 2.0

Introduction Transformations 5/15

Page 32: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinates and Points

Cartesian Coordinates

(3,2)

3

2

(0,0)

aa =

(32

)

The Point class represents a 2-dimensional point or vector:

a = new Point2D.Double(3.0, 2.0);double ax = a.getX(); // 3.0double ay = a.getY(); // 2.0

Introduction Transformations 5/15

Page 33: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinates and Points

Cartesian Coordinates

(3,2)

3

2

(0,0)

aa =

(32

)

The Point class represents a 2-dimensional point or vector:

a = new Point2D.Double(3.0, 2.0);double ax = a.getX(); // 3.0double ay = a.getY(); // 2.0

Introduction Transformations 5/15

Page 34: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Coordinates and Points

Cartesian Coordinates

(3,2)

3

2

(0,0)

aa =

(32

)

The Point class represents a 2-dimensional point or vector:

a = new Point2D.Double(3.0, 2.0);double ax = a.getX(); // 3.0double ay = a.getY(); // 2.0

Introduction Transformations 5/15

Page 35: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrices

Find[12

]

[1 −3−5 4

]

Matrices Transformations 6/15

Page 36: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrices

Find[12

]

[1 −3−5 4

]

Matrices Transformations 6/15

Page 37: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrices

Find[12

]

[1 −3−5 4

]

Matrices Transformations 6/15

Page 38: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrices

Find[12

] [1 −3−5 4

]

Matrices Transformations 6/15

Page 39: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]

=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 40: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]

=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 41: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]

=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 42: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 43: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 44: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 45: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 46: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Matrix Transformations

Matrices: operators for transforming vectors

[1 −3−5 4

] [12

]=

[−53

]

Ax = x′

x local coordinatesx′ screen coordinates

Matrices Transformations 7/15

Page 47: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Dilbert

public class DilbertTransextends JComponent {

dilbert D = new Dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

D.setColour(Color.black);D.paint(g2); // Screen coordinates

AffineTransform A = new AffineTransform();// Manipulate transformationg2.setTransform(A); // Apply transformD.setColour(Color.magenta);D.paint(g2);

}

Matrices Transformations 8/15

Page 48: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Dilbert

public class DilbertTransextends JComponent {

dilbert D = new Dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

D.setColour(Color.black);D.paint(g2); // Screen coordinates

AffineTransform A = new AffineTransform();// Manipulate transformationg2.setTransform(A); // Apply transformD.setColour(Color.magenta);D.paint(g2);

}

Matrices Transformations 8/15

Page 49: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Dilbert

public class DilbertTransextends JComponent {

dilbert D = new Dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

D.setColour(Color.black);D.paint(g2); // Screen coordinates

AffineTransform A = new AffineTransform();// Manipulate transformationg2.setTransform(A); // Apply transformD.setColour(Color.magenta);D.paint(g2);

}

Matrices Transformations 8/15

Page 50: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Dilbert

public class DilbertTransextends JComponent {

dilbert D = new Dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

D.setColour(Color.black);D.paint(g2); // Screen coordinates

AffineTransform A = new AffineTransform();// Manipulate transformationg2.setTransform(A); // Apply transformD.setColour(Color.magenta);D.paint(g2);

}

Matrices Transformations 8/15

Page 51: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Dilbert

public class DilbertTransextends JComponent {

dilbert D = new Dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

D.setColour(Color.black);D.paint(g2); // Screen coordinates

AffineTransform A = new AffineTransform();// Manipulate transformationg2.setTransform(A); // Apply transformD.setColour(Color.magenta);D.paint(g2);

}

Matrices Transformations 8/15

Page 52: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Dilbert

public class DilbertTransextends JComponent {

dilbert D = new Dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

D.setColour(Color.black);D.paint(g2); // Screen coordinates

AffineTransform A = new AffineTransform();// Manipulate transformationg2.setTransform(A); // Apply transformD.setColour(Color.magenta);D.paint(g2);

}

Matrices Transformations 8/15

Page 53: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]

Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 54: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]

Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 55: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]

Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 56: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]

Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 57: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 58: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 59: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 60: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 61: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotation Matrices

x′ = Rx[x ′

y ′

]=

[cos θ − sin θsin θ cos θ

] [xy

]

=

[x cos θ − y sin θx sin θ + y cos θ

]Rotation by θ

Rotation matrices leave the length of the vector unchanged.

|x′|2 = (x cos θ − y sin θ)2 + (x sin θ + y cos θ)2

= x2 + y2

= |x|2

Matrices Transformations 9/15

Page 62: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotations

Dilbert D =new Dilbert("./dilbert.txt");

. . .

AffineTransformation A =new AffineTransformation();

A.rotation(-Math.PI/12);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

Angles in radians:π radians = 180◦

Java2D rotationsincrease clockwise

Matrices Transformations 10/15

Page 63: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotations

Dilbert D =new Dilbert("./dilbert.txt");

. . .

AffineTransformation A =new AffineTransformation();

A.rotation(-Math.PI/12);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

Angles in radians:π radians = 180◦

Java2D rotationsincrease clockwise

Matrices Transformations 10/15

Page 64: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotations

Dilbert D =new Dilbert("./dilbert.txt");

. . .

AffineTransformation A =new AffineTransformation();

A.rotation(-Math.PI/12);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

Angles in radians:π radians = 180◦

Java2D rotationsincrease clockwise

Matrices Transformations 10/15

Page 65: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotations

Dilbert D =new Dilbert("./dilbert.txt");

. . .

AffineTransformation A =new AffineTransformation();

A.rotation(-Math.PI/12);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

Angles in radians:π radians = 180◦

Java2D rotationsincrease clockwise

Matrices Transformations 10/15

Page 66: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotations

Dilbert D =new Dilbert("./dilbert.txt");

. . .

AffineTransformation A =new AffineTransformation();

A.rotation(-Math.PI/12);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

Angles in radians:π radians = 180◦

Java2D rotationsincrease clockwise

Matrices Transformations 10/15

Page 67: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Rotations

Dilbert D =new Dilbert("./dilbert.txt");

. . .

AffineTransformation A =new AffineTransformation();

A.rotation(-Math.PI/12);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

Angles in radians:π radians = 180◦

Java2D rotationsincrease clockwise

Matrices Transformations 10/15

Page 68: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 69: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 70: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 71: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 72: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 73: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 74: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 75: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling

A.scale(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint();

[x ′

y ′

]=

[λxµy

]=

[λ 00 µy

] [xy

]

Diagonal matrices scale thevectorEqual entries on diagonal giveisotropic scalingUnequal entries on diagonal giveanisotropic scalingDilbert was scaled by:A.scale(2.0, 0.5);

Matrices Transformations 11/15

Page 76: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling to fit window

public class DilbertAutoscale extends JComponent {private Dilbert D = new dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

GeneralPath path = D.getpath(); // Path describing dilbertRectangle2D bbox = path.getBounds2D(); // Bounding box

AffineTransform A = new AffineTransform();A.scale(0.9*getWidth() / bbox.getMaxX(),

0.9*getHeight() / bbox.getMaxY());g2.transform(A);

D.setColour(Color.blue);D.paint(g2);

}

Exercise:Modify DilbertAutoScale to preserve Dilbert’s aspect ratio.

Matrices Transformations 12/15

Page 77: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling to fit window

public class DilbertAutoscale extends JComponent {private Dilbert D = new dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

GeneralPath path = D.getpath(); // Path describing dilbertRectangle2D bbox = path.getBounds2D(); // Bounding box

AffineTransform A = new AffineTransform();A.scale(0.9*getWidth() / bbox.getMaxX(),

0.9*getHeight() / bbox.getMaxY());g2.transform(A);

D.setColour(Color.blue);D.paint(g2);

}

Exercise:Modify DilbertAutoScale to preserve Dilbert’s aspect ratio.

Matrices Transformations 12/15

Page 78: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling to fit window

public class DilbertAutoscale extends JComponent {private Dilbert D = new dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

GeneralPath path = D.getpath(); // Path describing dilbertRectangle2D bbox = path.getBounds2D(); // Bounding box

AffineTransform A = new AffineTransform();A.scale(0.9*getWidth() / bbox.getMaxX(),

0.9*getHeight() / bbox.getMaxY());g2.transform(A);

D.setColour(Color.blue);D.paint(g2);

}

Exercise:Modify DilbertAutoScale to preserve Dilbert’s aspect ratio.

Matrices Transformations 12/15

Page 79: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling to fit window

public class DilbertAutoscale extends JComponent {private Dilbert D = new dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

GeneralPath path = D.getpath(); // Path describing dilbertRectangle2D bbox = path.getBounds2D(); // Bounding box

AffineTransform A = new AffineTransform();A.scale(0.9*getWidth() / bbox.getMaxX(),

0.9*getHeight() / bbox.getMaxY());g2.transform(A);

D.setColour(Color.blue);D.paint(g2);

}

Exercise:Modify DilbertAutoScale to preserve Dilbert’s aspect ratio.

Matrices Transformations 12/15

Page 80: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling to fit window

public class DilbertAutoscale extends JComponent {private Dilbert D = new dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

GeneralPath path = D.getpath(); // Path describing dilbertRectangle2D bbox = path.getBounds2D(); // Bounding box

AffineTransform A = new AffineTransform();A.scale(0.9*getWidth() / bbox.getMaxX(),

0.9*getHeight() / bbox.getMaxY());g2.transform(A);

D.setColour(Color.blue);D.paint(g2);

}

Exercise:Modify DilbertAutoScale to preserve Dilbert’s aspect ratio.

Matrices Transformations 12/15

Page 81: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling to fit window

public class DilbertAutoscale extends JComponent {private Dilbert D = new dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

GeneralPath path = D.getpath(); // Path describing dilbertRectangle2D bbox = path.getBounds2D(); // Bounding box

AffineTransform A = new AffineTransform();A.scale(0.9*getWidth() / bbox.getMaxX(),

0.9*getHeight() / bbox.getMaxY());g2.transform(A);

D.setColour(Color.blue);D.paint(g2);

}

Exercise:Modify DilbertAutoScale to preserve Dilbert’s aspect ratio.

Matrices Transformations 12/15

Page 82: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Scaling to fit window

public class DilbertAutoscale extends JComponent {private Dilbert D = new dilbert("./dilbert.txt");. . .

public void paint(Graphics g) {Graphics2D g2 = (Graphics2D)g;

GeneralPath path = D.getpath(); // Path describing dilbertRectangle2D bbox = path.getBounds2D(); // Bounding box

AffineTransform A = new AffineTransform();A.scale(0.9*getWidth() / bbox.getMaxX(),

0.9*getHeight() / bbox.getMaxY());g2.transform(A);

D.setColour(Color.blue);D.paint(g2);

}

Exercise:Modify DilbertAutoScale to preserve Dilbert’s aspect ratio.

Matrices Transformations 12/15

Page 83: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Axis Aligned Bounding Box

Smallest axis-parallel rectangle containing the object

Matrices Transformations 13/15

Page 84: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Axis Aligned Bounding Box

Smallest axis-parallel rectangle containing the object

Matrices Transformations 13/15

Page 85: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Axis Aligned Bounding Box

Smallest axis-parallel rectangle containing the object

Matrices Transformations 13/15

Page 86: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 87: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 88: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 89: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 90: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 91: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 92: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 93: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Shear

A.shear(λ, µ);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + λy

y

]=

[1 λ0 1

] [xy

][

x ′

y ′

]=

[x

µx + y

]=

[1 0µ 1

] [xy

]

One coordinate is leftunchanged.

Dilbert was sheared with[1 10 1

]A.shear(1, 0);

Matrices Transformations 14/15

Page 94: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Translation

A.translate(150.0, 50.0);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + txy + ty

]

=

[xy

] [txty

]x′ = x + t

Matrices Transformations 15/15

Page 95: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Translation

A.translate(150.0, 50.0);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + txy + ty

]

=

[xy

] [txty

]x′ = x + t

Matrices Transformations 15/15

Page 96: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Translation

A.translate(150.0, 50.0);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + txy + ty

]

=

[xy

] [txty

]x′ = x + t

Matrices Transformations 15/15

Page 97: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Translation

A.translate(150.0, 50.0);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + txy + ty

]

=

[xy

] [txty

]x′ = x + t

Matrices Transformations 15/15

Page 98: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Translation

A.translate(150.0, 50.0);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + txy + ty

]

=

[xy

] [txty

]x′ = x + t

Matrices Transformations 15/15

Page 99: Transformations - empslocal.ex.ac.ukempslocal.ex.ac.uk/people/staff/pjk205/ECM2410/slides04.pdf · Transformations Coordinate systems The reason Vectors and matrices The maths Homogeneous

Translation

A.translate(150.0, 50.0);g2.transform(A);D.setColour(Color.magenta);D.paint(g2);

[x ′

y ′

]=

[x + txy + ty

]

=

[xy

] [txty

]x′ = x + t

Matrices Transformations 15/15