transformation - github pages · fisher et al. (2012) placement of objects cs 148: introduction to...

75
CS 148: Summer 2016 Introduction of Graphics and Imaging Zahid Hossain Transformation http://www.pling.org.uk/cs/cgv.html

Upload: others

Post on 03-Apr-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CS 148: Summer 2016Introduction of Graphics and ImagingZahid Hossain

Transformation

http://www.pling.org.uk/cs/cgv.html

Page 2: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

Fisher etal.(2012)

PlacementofObjects

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 2

Page 3: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

Fisher etal.(2012)

PlacementofObjects

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3

Oriented

Page 4: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

Fisher etal.(2012)

PlacementsofObjects

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 4

Translated

Page 5: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

PointsandVectors

5

p

Originx

y

z

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

Page 6: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

PointsandVectors

6

Originx

y

z

Vector Points

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain

Page 7: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

Transformations

• What?Justfunctionsactingonpoints:

• Why?• Viewing:• Convertbetweencoordinatessystems• Virtualcamera,e.g.perspectiveprojections

• Modeling:• Createobjectsinaconvenientorientation• Usemultiple instancesofagivenshape• Kinematics– characters/robots

7

Page 8: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

LinearTransformation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 8

Page 9: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

LinearTransformation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 9

Page 10: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

LinearTransformation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 10

Page 11: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

LinearTransformation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 11

Lines Map to Lines

Page 12: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CommonTransformation

12

Rotate Scale Shear

Page 13: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

13

Page 14: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

ComposingTransformations

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 14

FirstRotate45°

Page 15: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

ComposingTransformations

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 15

ThenScale2xalongy

Page 16: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

ComposingTransformations

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 16

RotationScale

Orderoftransformations

Page 17: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

ComposingTransformation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 17

Rotate->Scale Scale->Rotate

Not Commutative

Page 18: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

Translation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 18

Page 19: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 19

For any non-zero c

Page 20: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 20

Page 21: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 21

Page 22: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 22

4DHomogenous Coordinate 3DCartesianCoordinate

Page 23: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 23

w=1

w-axis

x,y-axis

(x,y,w)

(x/w,y/w,1)

Page 24: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 24

z=1

z-axis

x,y-axis

Decreasew

Page 25: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 25

z=1

z-axis

x,y-axis

Decreasew

Page 26: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 26

Page 27: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HomogenousCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 27

Represents a Vector!(Homogenous Coordinates express both Vectors and Points)

Page 28: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

BacktoTranslation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 28

Homogenous CoordinateHomogenous Coordinate

Page 29: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 29

(3,4,2):

Convert3DCartesianCoordinatetoHomogenousCoordinate

Page 30: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 30

(3,4,2):(3,4,2,1)

Convert3DCartesianCoordinatetoHomogenousCoordinate

Page 31: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 31

(3,4,2):(3,4,2,1)

Convert3DCartesianCoordinatetoHomogenousCoordinate

ConvertHomogenousCoordinatetoCartesianCoordinate

(3,4,2,2) :

Page 32: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 32

(3,4,2):(3,4,2,1)

Convert3DCartesianCoordinatetoHomogenousCoordinate

ConvertHomogenousCoordinatetoCartesianCoordinate

(3,4,2,2) :(1.5,2,1)

Page 33: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 33

Rotateaboutthecenterofthebox

Page 34: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 34

Translatetocenter

Page 35: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 35

Rotate

Page 36: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

SomeExercise

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 36

Translateback

Page 37: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 37

Page 38: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 38

Page 39: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 39

Page 40: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem:Rotation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 40

Page 41: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem:Rotation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 41

Page 42: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem:Rotation

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 42

Page 43: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem:Hierarchy

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 43

Page 44: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem:Hierarchy

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 44

Page 45: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem:Hierarchy

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 45

Page 46: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

InterpretingTransformations

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 46

Page 47: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

TwoInterpretations

• WithrespecttoGlobalFrame• WithrespecttoLocalFrame

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 47

Page 48: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CoordinateSystem:Hierarchy

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 48

Page 49: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

w.r.t GlobalFrame

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 49

Combined=Translate(0,1)Rotate(45°)Translate(1,1)

Translate(1,1) Rotate(45°) Translate(0,1)

OrderofTransforms

Page 50: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

w.r.t LocalFrame

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 50

Combined=Translate(0,1)Rotate(45°)Translate(1,1)

Translate(0,1) Rotate(45°) Translate(1,1)

OrderofTransform

Page 51: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

w.r.t LocalFrame

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 51

Combined=Translate(0,1)Rotate(45°)Translate(1,1)

Translate(0,1) Rotate(45°) Translate(1,1)

OrderofTransform

Both interpretations are equivalent

Page 52: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HierarchicalModeling

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 52

translate(0,4)drawTorso()pushMatrix()

translate(1.5,0)rotateX(leftHipRotate)drawThigh()pushMatrix()

translate(0,-2)rotateX(leftKneeRotate)drawLeg()...

popMatrix()popMatrix()pushMatrix()

translate(-1.5,0)rotateX(rightHipRotate)// Draw the right side...

...x

y

CurrentMatrix =Translate(0,4)

MatrixStack

Page 53: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HierarchicalModeling

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 53

translate(0,4)drawTorso()pushMatrix()

translate(1.5,0)rotateX(leftHipRotate)drawThigh()pushMatrix()

translate(0,-2)rotateX(leftKneeRotate)drawLeg()...

popMatrix()popMatrix()pushMatrix()

translate(-1.5,0)rotateX(rightHipRotate)// Draw the right side...

...x

y

CurrentMatrix =Translate(0,4)

MatrixStack

Translate(0,4)

Page 54: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HierarchicalModeling

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 54

translate(0,4)drawTorso()pushMatrix()

translate(1.5,0)rotateX(leftHipRotate)drawThigh()pushMatrix()

translate(0,-2)rotateX(leftKneeRotate)drawLeg()...

popMatrix()popMatrix()pushMatrix()

translate(-1.5,0)rotateX(rightHipRotate)// Draw the right side...

...x

y

CurrentMatrix =translate(0,4)translate(1.5,0)rotateX(leftHipRotate)translate(0,-2)rotate(leftKneeRotate)

MatrixStack

translate(0,4)translate(0,4)translate(1.5,0)rotateX(leftHipRotate)

Page 55: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HierarchicalModeling

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 55

translate(0,4)drawTorso()pushMatrix()

translate(1.5,0)rotateX(leftHipRotate)drawThigh()pushMatrix()

translate(0,-2)rotateX(leftKneeRotate)drawLeg()...

popMatrix()popMatrix()pushMatrix()

translate(-1.5,0)rotateX(rightHipRotate)// Draw the right side...

...x

y

CurrentMatrix =translate(0,4)translate(1.5,0)rotateX(leftHipRotate)

MatrixStack

translate(0,4)

Page 56: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HierarchicalModeling

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 56

translate(0,4)drawTorso()pushMatrix()

translate(1.5,0)rotateX(leftHipRotate)drawThigh()pushMatrix()

translate(0,-2)rotateX(leftKneeRotate)drawLeg()...

popMatrix()popMatrix()pushMatrix()

translate(-1.5,0)rotateX(rightHipRotate)// Draw the right side...

...x

y

CurrentMatrix =translate(0,4)

MatrixStack

Page 57: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HierarchicalModeling

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 57

translate(0,4)drawTorso()pushMatrix()

translate(1.5,0)rotateX(leftHipRotate)drawThigh()pushMatrix()

translate(0,-2)rotateX(leftKneeRotate)drawLeg()...

popMatrix()popMatrix()pushMatrix()

translate(-1.5,0)rotateX(rightHipRotate)// Draw the right side...

...x

y

CurrentMatrix =translate(0,4)translate(-1.5,0)rotateX(rightHipRotate)

MatrixStack

translate(0,4)

Page 58: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

HierarchicalModeling

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 58

x

y

Torso

RightThigh

RightLeg

translate(0,4)

translate(1.5,0)rotateX(rightHipRotate)

translate(0,-2)rotateX(rightLegRotate)popM

atrix()LeftSide

pushMatrix()

pushMatrix()

pushMatrix()

Page 59: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CameraandProjectionMatrices

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 59

Page 60: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

3Dto2DConversion

• Theworldisin3D• ButourScreenisin2D• Imagineourscreenisacameralookingoutintotheworld.• Tasks

1. Convert3DworldcoordinatestoCameraCoordinates2. ProjecttheCameraCoordinateon2Dscreen

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 60

Page 61: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CameraMatrix

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 61

Page 62: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CameraMatrix

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 62

Homework!

Page 63: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

ProjectionMatrix(Basic)

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 63

Page 64: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

ProjectionMatrix(Basic)

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 64

Page 65: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

NormalizedDeviceCoordinates

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 65

http://www.songho.ca/opengl/gl_projectionmatrix.html

NDC(NormalizedDeviceCoordinate)

Page 66: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

OpenGLProjectionMatrix

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 66

Note the –n and –f (to be consistent with OpenGL)

Page 67: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

OpenGLProjectionMatrix

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 67

Page 68: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

OpenGLProjectionMatrix

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 68

Similarly for y

Page 69: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

OpenGLProjectionMatrix

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 69

z’ is a little tricky

SolvingforAandB

Page 70: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

OpenGLProjectionMatrix

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 70

Page 71: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

Non-LinearityinZ

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 71

-8 -6 -4 -2

-1.0

-0.5

0.5

1.0

1. Monotonic:valueskeepsincreasingaszgoesin–vedirection2. Resolutiondecreasesaszdecrease(along–ve)ordepthincreases

Page 72: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

Non-LinearityinZ

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 72

-8 -6 -4 -2

-1.0

-0.5

0.5

1.0

1. Monotonic:valueskeepsincreasingaszgoesin–vedirection2. Resolutiondecreasesaszdecrease(along–ve)ordepthincreases

For Later:Has interesting effects in Depth Buffering

Page 73: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

StartLearningOpenGLNow

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 73

Page 74: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

StartLearningOpenGLNow

CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 74

Suggestions OnlyFor OpenGL 3.3: http://learnopengl.com

For OpenGL < 2.0: Any GLUT or FreeGLUT tutorial

Page 75: Transformation - GitHub Pages · Fisher et al. (2012) Placement of Objects CS 148: Introduction to Computer Graphics and Imaging (Summer 2016) – Zahid Hossain 3 Oriented

CS 148: Summer 2016Introduction of Graphics and ImagingZahid Hossain

Transformation

http://www.pling.org.uk/cs/cgv.html