honours graphics 2008

16
Honours Graphics 2008 Session 3

Upload: duke

Post on 20-Mar-2016

46 views

Category:

Documents


1 download

DESCRIPTION

Honours Graphics 2008. Session 3. Today’s focus. Perspective and orthogonal projection Quaternions Graphics camera. Projections. Visualizing 3D data on a 2D screen requires projection of the data onto a 2D plane Several projection models exist, with varying qualities - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Honours Graphics 2008

Honours Graphics 2008

Session 3

Page 2: Honours Graphics 2008

Today’s focus

• Perspective and orthogonal projection

• Quaternions

• Graphics camera

Page 3: Honours Graphics 2008

Projections

• Visualizing 3D data on a 2D screen requires projection of the data onto a 2D plane

• Several projection models exist, with varying qualities

• We’re interested in orthogonal and perspective projection

Page 4: Honours Graphics 2008

Perspective projection

Page 5: Honours Graphics 2008

Perspective projection, cont.• Starting from world coordinate space:

Page 6: Honours Graphics 2008

Increasing focal length and distance of the camera to infinity changes perspective into orthogonal projection

Page 7: Honours Graphics 2008

Orthogonal projection• Flat, 2D projection• Used when precise profiles or measurements need to be displayed • Special case of perspective projection, when focal length

approaches infinity

Page 8: Honours Graphics 2008

Quaternions

• Developed by Sir William Rowan Hamilton in 1843

• Generally superceded by vectors and matrices, but still very useful in applied mathematics and computer graphics

• Specifically useful to compute 3D rotations• Consists of scalar and “vector” components

Page 9: Honours Graphics 2008

Quaternions, cont.

• Defined as an extension to the complex numbers: three components i, j and k all are squareroots of -1, hence

• Furthermore

Page 10: Honours Graphics 2008

Quaternions, cont.

• Finally

• Quaternion addition and subtraction

Page 11: Honours Graphics 2008

Quaternions, cont.• Magnitude of a quaternion

• Quaternion multiplication

Page 12: Honours Graphics 2008

Quaternions, cont.

• For graphics purposes a unit quaternion is used, which has the property that

• Unit quaternions represent rotation / orientation

Page 13: Honours Graphics 2008

Quaternions, cont.

• Quaternion to rotation matrix conversion

Page 14: Honours Graphics 2008

Graphics camera

• Both DirectX and OpenGL expose camera parameters that consist of

• View position• View target• Relative view-up direction

Page 15: Honours Graphics 2008

Camera commands• OpenGL

void gluLookAt(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ )

• DirectX

D3DXMatrixLookAtLH(mat, eye, center, up);DX9Device.SetTransform(D3DTS_VIEW, mat);

Page 16: Honours Graphics 2008

Homework

• Write a camera library that makes use of quaternions. Allow for keyboard and mouse input to control the camera.

• For next session