130
Computer Graphics Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi

Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Computer Graphics

Subodh Kumar

Dept of Computer Sc. & Engg. IIT Delhi

Page 2: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Model Representation

Page 3: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Model Representation

! List of triangles ! eg, Begin(TRI ); Vertex(v0);.. End(); ! Or even, Begin(TRISTRIP ); Vertex(v0);.. End();

Page 4: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Model Representation

! List of triangles ! eg, Begin(TRI ); Vertex(v0);.. End(); ! Or even, Begin(TRISTRIP ); Vertex(v0);.. End();

! Mesh ! Vertices & Connectivity ! eg, InterleavedArrays(); DrawElements(); ! Displaylists, VBO

Page 5: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Model Representation

! List of triangles ! eg, Begin(TRI ); Vertex(v0);.. End(); ! Or even, Begin(TRISTRIP ); Vertex(v0);.. End();

! Mesh ! Vertices & Connectivity ! eg, InterleavedArrays(); DrawElements(); ! Displaylists, VBO

! Instanced ! aka Scene graph

Page 6: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

Sphere

Face Mesh

Cylinder

Page 7: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

T

Sphere

Face Mesh

Cylinder

Page 8: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

T

Sphere

Face Mesh

Cylinder

Page 9: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

T

Sphere

Face Mesh

Cylinder

Page 10: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

T

Sphere

Face Mesh

Cylinder

T’

Page 11: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

T

Sphere

Face Mesh

Cylinder

T’

Page 12: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

T

Sphere

Face Mesh

BotArmy

Cylinder

T’

Page 13: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

World

T

Sphere

Face Mesh

BotArmy

Cylinder

T’

Page 14: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph

Robot

BodyHead

ArmTrunk Mesh

Leg Mesh

EyeMouth Mesh

World

T

Sphere

Face Mesh

BotArmy

Cylinder

T0

T1

T2

T3

T4

Page 15: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

RobotBodyHead

Arm

World

BotArmy

Page 16: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal

RobotBodyHead

Arm

World

BotArmy

Page 17: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix

RobotBodyHead

Arm

World

BotArmy

Page 18: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

RobotBodyHead

Arm

World

BotArmy

Page 19: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix

RobotBodyHead

Arm

World

BotArmy

Page 20: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

RobotBodyHead

Arm

World

BotArmy

Page 21: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix

RobotBodyHead

Arm

World

BotArmy

Page 22: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face

RobotBodyHead

Arm

World

BotArmy

Page 23: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face! …

RobotBodyHead

Arm

World

BotArmy

Page 24: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face! …

! Un-multiply Head->Face Matrix

RobotBodyHead

Arm

World

BotArmy

Page 25: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face! …

! Un-multiply Head->Face Matrix! Un-multiply Robot->Head matrix

RobotBodyHead

Arm

World

BotArmy

Page 26: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face! …

! Un-multiply Head->Face Matrix! Un-multiply Robot->Head matrix! Multiply Robot->Body matrix

RobotBodyHead

Arm

World

BotArmy

Page 27: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face! …

! Un-multiply Head->Face Matrix! Un-multiply Robot->Head matrix! Multiply Robot->Body matrix! … Robot

BodyHead

Arm

World

BotArmy

Page 28: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face! …

! Un-multiply Head->Face Matrix! Un-multiply Robot->Head matrix! Multiply Robot->Body matrix! …! Un-multiply Robot->Body matrix

RobotBodyHead

Arm

World

BotArmy

Page 29: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scene Graph Draw

! DFS Traversal! Multiply World->Army matrix! For each robot:

! Multiply Army->Robot matrix! Multiply Robot->Head matrix

! Multiply Head->Face Matrix! Draw Face! …

! Un-multiply Head->Face Matrix! Un-multiply Robot->Head matrix! Multiply Robot->Body matrix! …! Un-multiply Robot->Body matrix! …

RobotBodyHead

Arm

World

BotArmy

Page 30: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

OpenGL Matrix Stack

! glPushMatrix() ! glMultMatrix(M1)

! glPopMatrix() ! glLoadMatrix()

Page 31: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

OpenGL Matrix Stack

! glPushMatrix() ! glMultMatrix(M1)

! glPopMatrix() ! glLoadMatrix()

M0

Page 32: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

OpenGL Matrix Stack

! glPushMatrix() ! glMultMatrix(M1)

! glPopMatrix() ! glLoadMatrix()

M0

M0 M0

Page 33: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

OpenGL Matrix Stack

! glPushMatrix() ! glMultMatrix(M1)

! glPopMatrix() ! glLoadMatrix()

M0

M0 M0

M0 M0*M1

Page 34: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

OpenGL Matrix Stack

! glPushMatrix() ! glMultMatrix(M1)

! glPopMatrix() ! glLoadMatrix()

M0

M0

M0 M0

M0 M0*M1

Page 35: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation

! Change an object to another ! Transform all points of an object ! E.g.,

! Move it, Translate ! Re-orient it, Rotate ! Re-size it, Scale ! Skew, etc.

! Want to compose a sequence of transformations

Page 36: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Interior of Triangle

V0

V1

V2

Page 37: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Interior of Triangle

V0

V1

V2

Page 38: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Interior of Triangle

V0

V1

V2

Page 39: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Interior of Triangle

V0

V1

V2

Page 40: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Interior of Triangle

V0

V1

V2

V

Page 41: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Interior of Triangle

V0

V1

V2

(1-t ) V1 + t V2

t =(V-V1)/(V2-V1)V

Page 42: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Interior of Triangle

V1

V2

aV0+bV1+cV2

V0

V

a =Area(V2V V1)/ Area(V2V0V1)

. .

Page 43: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Simple Xform Types

! Rigid body ! No length changes

! Translation, Rotation

! Linear ! aT(P) + bT(Q) = T(aP+bQ)

! Rotation, Scale, nxn Matrix-multiplication

! Affine ! aT(P) + bT(Q) = T(aP+bQ) + K ! Preserves parallel lines ! Translation, Rotation, Scale ! Linear in projective space, n+1xn+1 matrix

multiplication ! Projective

Page 44: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Translation

Page 45: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Translation

Page 46: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Translation

Page 47: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Translation

Page 48: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Translation

tx, ty, tz

Page 49: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 50: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

θ

Page 51: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

θ

Vector, θ

Page 52: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

θ

Vector, θ

Page 53: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

Vector, θ

Page 54: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

α

Vector, θ

Page 55: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

r

x = r cos α

θ

α

Vector, θ

Page 56: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

r

x = r cos αr cos(α+θ)

θ

α

Vector, θ

Page 57: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

r

x = r cos αr cos(α+θ)

θ

α

Vector, θ

x´= r cosαcosθ - r sinαsinθ

Page 58: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

r

x = r cos αr cos(α+θ)

θ

α

Vector, θ

x´= r cosαcosθ - r sinαsinθ = xcosθ - ysinθ

Page 59: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

r

x = r cos αr cos(α+θ)

θ

cos θ -sin θ sin θ cos θ

α

Vector, θ

x´= r cosαcosθ - r sinαsinθ = xcosθ - ysinθ

x y

Page 60: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

r

r

x = r cos αr cos(α+θ)

θ

cos θ -sin θ sin θ cos θ

cos θ -sin θ 0 sin θ cos θ 0 0 0 1

3D

α

Vector, θ

x´= r cosαcosθ - r sinαsinθ = xcosθ - ysinθ

x y

Page 61: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 62: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 63: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 64: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 65: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 66: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 67: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

Page 68: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

1.Translate to origin 2.Rotate 3.Translate back

Page 69: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

1.Translate to origin 2.Rotate 3.Translate back

Page 70: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

1.Translate to origin 2.Rotate 3.Translate back

Page 71: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

1.Translate to origin 2.Rotate 3.Translate back

Page 72: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation

1.Translate to origin 2.Rotate 3.Translate back

Page 73: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scale

Page 74: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scale

Page 75: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scale

Page 76: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scale

Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1

Page 77: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scale

Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1

Page 78: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scale

Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1

Page 79: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Scale

Sx 0 0 0 0 Sy 0 0 0 0 Sz 0 0 0 0 1

Point, Sx, Sy, Sz

Page 80: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Translation

1 0 0 tx

0 1 0 ty

0 0 1 tz

0 0 0 1

x y z w

Homogeneous Coordinates

Page 81: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Projective Space

! n-dimensional projective space is constructed from an n+1-dimensional vector space ! Where, aP = P ! (0,0,0,…) is undefined

! The original space is a projection of this n+1-dimensional vector space ! x, y, z, w = x/w, y/w, z/w, 1 = affine space ! Except when w=0: x, y, z, 0 = x/z, y/z, 1, 0

! Except when z = 0 … ! w is called the homogeneous coordinate

Page 82: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Projective Plane

x

yw

w=1

x = uw, y = vw, ie, uw u vw = v w 1

Page 83: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Projective Plane

x

yw

w=1

x = uw, y = vw, ie, uw u vw = v w 1

Page 84: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

2

664

1 0 0 dx

0 1 0 dy

0 0 1 dz

0 0 0 1

3

775

2

664

x

y

z

1

3

775=

2

664

x+ dx

x+ dy

z + dz

1

3

775

2

664

sx 0 0 0

0 sy 0 0

0 0 sz 0

0 0 0 1

3

775

2

664

x

y

z

1

3

775=

2

664

x.sx

x.sy

z.sz

1

3

775

2

664

cos↵ sin↵ 0 0

� sin↵ cos↵ 0 0

0 0 1 0

0 0 0 1

3

775

2

664

x

y

z

1

3

775=

2

664

x cos↵+ y sin↵

�x sin↵+ y cos↵

z

1

3

775

Examples of Xform Matrices

Translation by dx, dy, dz Scaling by sx, sy, sz

Rotation by α (about Z)

Page 85: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Change of Basis

! New basis: ! Orthonormal axes:

V1, V2, V3 ! Origin: O

2

664

— V1 — 0— V2 — 0— V3 — 0

0 0 0 1

3

775

2

664

1 0 0 �Ox

0 1 0 �Oy

0 0 1 �Oz

0 0 0 1

3

775

Page 86: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation about Axis

19

u,v,w

ɵ

2

4x

0

y

0

z

0

3

5=

2

4u.u(1� cos ✓) + cos ✓ w.u(1� cos ✓)� w sin ✓ u.w(1� cos ✓)� v sin ✓

v.u(1� cos ✓) + w sin ✓ w.u(1� cos ✓) + cos ✓ v.w(1� cos ✓)� u sin ✓

w.u(1� cos ✓)� v sin ✓ w.u(1� cos ✓)� u sin ✓ w.w(1� cos ✓) + cos ✓

3

5

2

4x

y

z

3

5

Page 87: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation Recap

! General transformation = ! Composition of known special transformations

! Transformation is equivalent to an inverse change of basis

! Be mindful of space in which ! the transformation is specified ! the vertex/vector is specified

! [M1 M2 M3 … Mk] V = ! Mk then Mk-1 until M1 in world-coordinates

! M1, then M2, until Mk in object-coordinates

Page 88: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Fixed frame

! T(1,0) ! R(90) ! R T p

Page 89: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Fixed frame

! T(1,0) ! R(90) ! R T p

Page 90: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Fixed frame

! T(1,0) ! R(90) ! R T p

Page 91: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Fixed frame

! T(1,0) ! R(90) ! R T p

Page 92: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Fixed frame

! T(1,0) ! R(90) ! R T p

Page 93: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Fixed frame

! T(1,0) ! R(90) ! R T p

Page 94: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Local frame

! T(1,0) ! R(90) ! R T p

Page 95: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Local frame

! T(1,0) ! R(90) ! R T p

Page 96: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Local frame

! T(1,0) ! R(90) ! R T p

Page 97: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Composition: Local frame

! T(1,0) ! R(90) ! R T p

Page 98: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Projection

! Projection = dimension reduction ! 3D " 2D in our case ! 3D lines map to 2D points ! Parallel

! Orthographic ! Oblique

! Projective

Page 99: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Perspective

! Transform plane of projection to Z = -1

Z = -1

Y

Z O

yy'

z

y'/-1 = y/z, or y' = -y/z and x' = -x/z

2

664

1 0 0 00 1 0 00 0 1 00 0 �1 1

3

7750

Page 100: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Perspective II

! Also normalize the image space ! Image X, Y lie in [-1:1]

Z = zv

y

ZO

zv tan(θ)

z

y' = zv y/z. Normalized y', call it y'' = y'/(zv tanθ) = y cotθ/z

θ FOV/2

Image Plane

y'

Page 101: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Perspective III

! What if we also want Z to lie in [0:1] ! Znear = 0

! Zfar = 1

Page 102: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Viewport

! What if we want ! X to lie in [0:Screen-Width] ! Y to lie in [0:Screen-Height]

! Xscreen = (Ximage + 1)/2 * Width

! Yscreen = (Yimage + 1)/2 * Height

Page 103: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n

d

Page 104: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0

n

d

Page 105: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0nTd = 0

n

d

Page 106: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0nTd = 0=> n’T Md must be 0

n

d

Page 107: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0nTd = 0=> n’T Md must be 0=> (M’n)T Md = 0

n

d

Page 108: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0nTd = 0=> n’T Md must be 0=> (M’n)T Md = 0=> nTM’T Md = 0

n

d

Page 109: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0nTd = 0=> n’T Md must be 0=> (M’n)T Md = 0=> nTM’T Md = 0=> M’T M = k I

n

d

Page 110: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0nTd = 0=> n’T Md must be 0=> (M’n)T Md = 0=> nTM’T Md = 0=> M’T M = k I=> M’T = k M-1

n

d

Page 111: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Transformation of Normals

n.d = 0nTd = 0=> n’T Md must be 0=> (M’n)T Md = 0=> nTM’T Md = 0=> M’T M = k I=> M’T = k M-1

=> M’ = (M-1)T k = 1

n

d

Page 112: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

3D Interaction

! Specify point (3 DOF) ! Specify orientation (3 DOF) ! Navigate (6 DOF)

! Manipulate object ! Manipulate eye/walk ! Specify path

! Select an object or region in space ! Find out its location and orientation

30

Page 113: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

3D Interface! Mouse provide a 2D input (+ buttons)

! 2D location ! Up-down, Left-right motion ! 2D rotation

! 3D navigation has 6 DOF ! Up / Down ! Forward / Backward ! Left / Right ! Pitch (transverse axis) ! Yaw (normal axis) ! Roll (longitudinal axis)

31

cf Hoffman

Yaw

Pitch

Roll

Page 114: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Trackball Interface

! Inspect an object ! Imagine rotating a sphere by a handle

! Map planar 2D motion onto unit sphere ! Raise old position <x0, z0> to <x0, y0, z0>

! Raise new position <x1, z1> to <x1, y1, z1> ! Find rotation that moves handle from old to

new

Page 115: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Trackball

Page 116: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Trackball

! p1: x12+y1

2+z12 = 1

Page 117: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Trackball

! p1: x12+y1

2+z12 = 1

! p2: x22+y2

2+z22 = 1

Page 118: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Trackball

! p1: x12+y1

2+z12 = 1

! p2: x22+y2

2+z22 = 1

! Ball rotates about the axis formed by p1 and p2

! p1 X p2

Page 119: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Trackball

! p1: x12+y1

2+z12 = 1

! p2: x22+y2

2+z22 = 1

! Ball rotates about the axis formed by p1 and p2

! p1 X p2

! Rotation angle proportional to the distance p1p2

! Or simply ||p1 X p2||

Page 120: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Trackball

! p1: x12+y1

2+z12 = 1

! p2: x22+y2

2+z22 = 1

! Ball rotates about the axis formed by p1 and p2

! p1 X p2

! Rotation angle proportional to the distance p1p2

! Or simply ||p1 X p2||

! What happens if the object is not at the origin?

Page 121: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation by Euler angles

34

Yaw

Pitch

Roll

Page 122: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation by Euler angles

34

Yaw

Pitch

Roll

Gimbal Lock

Page 123: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Rotation by Euler angles

34

Yaw

Pitch

Roll

Gimbal Lock

! Interpolation, Composition is non-intuitive

Page 124: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Quaternions

! Relates two vectors ! Like a vector relates two points

! q = <s, x, y, z> = <s,v> = s + xi + yj + zk ! Scalar, Vector: relates length and orientation ! cos(θ/2) + U sin (θ/2)

Quaternion multiplication: q1q2 = ( s1s2 – v1.v2, s1v1 + s2v2 + v1 x v2) Quaternion inverse: If q = (s,v), then q-1 = (s,-v)/||q||2 Apply quaternion to p: P' = q P q-1

Page 125: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Quaternions

! Relates two vectors ! Like a vector relates two points

! q = <s, x, y, z> = <s,v> = s + xi + yj + zk ! Scalar, Vector: relates length and orientation ! cos(θ/2) + U sin (θ/2)

Quaternion multiplication: q1q2 = ( s1s2 – v1.v2, s1v1 + s2v2 + v1 x v2) Quaternion inverse: If q = (s,v), then q-1 = (s,-v)/||q||2 Apply quaternion to p: P' = q P q-1 , P = (0, p)

Page 126: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Quaternions

! Relates two vectors ! Like a vector relates two points

! q = <s, x, y, z> = <s,v> = s + xi + yj + zk ! Scalar, Vector: relates length and orientation ! cos(θ/2) + U sin (θ/2)

Quaternion multiplication: q1q2 = ( s1s2 – v1.v2, s1v1 + s2v2 + v1 x v2) Quaternion inverse: If q = (s,v), then q-1 = (s,-v)/||q||2 Apply quaternion to p: P' = q P q-1 (0, p') = , P = (0, p)

Page 127: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Quaternion Rotation

p' = s2p + v(p.v) + 2s(v x p) + v x (v x p)

36

Page 128: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

Linear Interpolation

37

Lerp(t,a, b) = (1� t)a+ tb, 0 t 1

Linear

(Point a and b)

Page 129: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

! Euclidean space interpolation:

Linear Interpolation

37

Lerp(t,a, b) = (1� t)a+ tb, 0 t 1

Linear

(Point a and b)

Page 130: Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhisubodh/courses/CSL781/pdfslides/transformatio… · Subodh Kumar Dept of Computer Sc. & Engg. IIT Delhi. Model Representation. Model

! Euclidean space interpolation:

! Spherical interpolation

Linear Interpolation

37

Lerp(t,a, b) = (1� t)a+ tb, 0 t 1

Slerp(t,a, b) =sin((1� t)✓)

sin ✓a+

sin(t✓)

sin ✓b, 0 t 1

LinearSpherical

(Point a and b)

(Vector a and b) θ = arccos(a.b)