CS代考计算机代写 Computer Graphics

Computer Graphics
Jochen Lang
jlang@uottawa.ca
Faculté de génie | Faculty of Engineering
Jochen Lang, EECS jlang@uOttawa.ca

This Lecture
• Coordinate Transformations
– Tomas Akenine-Möller et al., Chapter 4.2
– Marschner and Shirley, Chapters 6.2.2, 6.4-6.5 – Inverse transforms
– Normal transforms
– Coordinate transforms
Jochen Lang, EECS jlang@uOttawa.ca

Inverse Transformation
• Mathematical inverse is the geometric inverse:
􏰖𝟏
􏰖𝟏
Jochen Lang, EECS jlang@uOttawa.ca

Inverse Transformation
• Finding the inverse:
– Orthonormal matrices
• Rigid body transforms
– Adjoint via conjugate transpose (determinant and cofactors)
• Non-singular matrices – SVD
• Enables “solutions” for singular and non-square matrices
Jochen Lang, EECS jlang@uOttawa.ca

Orthonormal Matrices
• Orthonormal matrix
– A square matrix with columns (and rows) are orthogonal unit vectors. The set of columns (or rows) form a set of orthonormal vectors (all vectors are unit length and are at an right angle to each other).
• The inverse of an orthonormal is its transpose
􏰖𝟏 𝐓
• Proof (in 2D)
– Given 𝐓 and 𝐓 and
– Then
𝐓􏰯
Jochen Lang, EECS jlang@uOttawa.ca

Rigid Body Transformations
• Only rotations and translation: – Preserves distances
– Preserves angles
• Inverse in 3D:
Jochen Lang, EECS jlang@uOttawa.ca

Quick Reminder:
Adjoint via Determinants
• Definition (in 3D):
􏰰􏰰􏰰 𝟏𝟏 𝟏𝟐 𝟏𝟑 􏰰 􏰰 􏰰
􏰯
– Given
• Example in 3D:
𝟏𝟏 𝟏𝟐 𝟏𝟑
𝟐𝟏 𝟐𝟐 𝟐𝟑 then 􏰖􏰉 𝟑𝟏 𝟑𝟐 𝟑𝟑
􏰉
􏰠 𝟐𝟏 𝟐𝟐 𝟐𝟑 􏰰 􏰰 􏰰
𝟑𝟏 𝟑𝟐 𝟑𝟑
– Calculate 􏰖􏰉?
Jochen Lang, EECS jlang@uOttawa.ca

Review: Verify at home!
• Cofactors are the determinants of the corresponding submatrices with the appropriate sign, e.g.:
Jochen Lang, EECS jlang@uOttawa.ca

Inverse via SVD
• Reminder:
– Inverse of Matrix product distributes the inverse to individual matrices (same as transpose)
􏰖𝟏 􏰖𝟏􏰖𝟏
– Using the svd on a matrix
– Inverse of the svd decomposition
𝑻 􏰖𝟏 𝑻 􏰖𝟏
– Distribute the inverse
𝑻 􏰖𝟏 􏰯􏰱􏰲 􏰖􏰉 􏰖􏰉
– But and are orthonormal
􏰖𝟏 􏰖𝟏𝐓
Jochen Lang, EECS jlang@uOttawa.ca

Normal Vector Transformation
• Normal vectors do not transform like points! – E.g., shear in x of a square
Images by F. Durand and B. Cutler, MIT.
Jochen Lang, EECS jlang@uOttawa.ca

Normal Vector Transformation
• Tangent vectors transform like points. – Clearly works for cubes
– Also works for spheres
• In general:
– Affine transformations preserve parallel lines but not angles!
– Affine transformations are rotations, translations, shears, scaling including reflections. (Everything we cover except translations).
Jochen Lang, EECS jlang@uOttawa.ca

Normal Vector Transformation
• Tangent and normal are normal to each other:
Jochen Lang, EECS jlang@uOttawa.ca

Another Look at Rotations
• Rotation matrix properties:
– Orthonormal matrix
– Columns describe a basis or Cartesian coordinate frame – Lets rotate the coordinate frame
Jochen Lang, EECS jlang@uOttawa.ca

Coordinate Transformation
Jochen Lang, EECS jlang@eecs.uOttawa.ca

Coordinate vs. Object Transform
Moving the Teapot
• Move object by 𝒛 and then by 𝒙 then
Jochen Lang, EECS jlang@uOttawa.ca

Coordinate vs. Object Transform
Moving the Coordinate Frame
• Moveframeby 𝒛 andthenby 𝒙 then
Jochen Lang, EECS jlang@uOttawa.ca

Column vs. Row Vector Convention
• The textbook, the lectures and most use the column vector convention BUT the row vector convention*) may also be found.
Computationally, there is no difference!
– *) Roberts [1966] introduced the row vector convention to graphics and much of early work in graphics and robotics used it, e.g. “Fundamentals of Interactive Computer Graphics”, J.D. Foley, A. van Dam, Addison-Wesley, 1982; and; “Robot Manipulators, mathematics, programming, and control“, R.P. Paul, MIT Press, 1981.
Jochen Lang, EECS jlang@uOttawa.ca

What does WebGL and OpenGL use?
• Incorrect questions since both convention are equivalent!
• BUT it is important that matrices are stored as 1D arrays in column-major order!
Jochen Lang, EECS jlang@uOttawa.ca

Next Lecture
• Scenegraph and Viewing Transformations – Scenegraph transforms
– Viewing and canonical viewing volume
Jochen Lang, EECS jlang@uOttawa.ca