Presentation is loading. Please wait.

Presentation is loading. Please wait.

HCT.

Similar presentations


Presentation on theme: "HCT."— Presentation transcript:

1 HCT

2 Geometric Transforms Rotation Translation Shear Scale
These are the operations done by HCT

3 Homogeneous What does homogeneous mean? -the same

4 Coordinate Transform What is a coordinate transform? P=(1,2)
Translate P by P1=(2,3)? P’ = P+P1 = (3,5). So translation is an example of a coordinate transform.

5 Scale, in 2D P=(1,1) Scale P by Sc=(2,3). P’ = P * Sc = (2,3)
P2=(1,4), now scale by Sc. P2’=(2,12).

6 Summary Translation is addition. Scaling is multiplication.
Both are coordinate transformations

7 Rotation Y X By Euler we get: Z=real Part + imaginary part
Z = r + im*I By polar coordinates we write an angle and a magnitude: Z = r exp(I * theta) X

8 Euler

9 Rotation

10 Summary Addition = translation Multiply by real numbers = scaling
Multiply by complex number = rotation These are different operations. They are not HCTs. HCTs concatenate all above operations into a single operation.

11 Learning Objectives Learn how 2D transformations are represented in 3D. Recognize the inverse matrix for a homogeneous transformation. Understand how the transformations also represent coordinate frame transformations. Understand the concept of a matrix stack.

12 2D Translation and 3D Translation

13 2D Rotation

14 Laws of Exponents

15 Use the trig identities
sin(A+B)=sin A cos B + cos A sin B cos(A+B)=cos A cos B - sin A sin B hint, write sin(theta1+theta2)

16 3D Rotation – Z Axis About the Z axis z y x

17 3D Rotation – X Axis About the Z axis z y x

18 3D Rotation – Y Axis About the Z axis z y x

19 Inverse Matrices The 3x3 rotation submatrix is orthogonal.
The inverse of the 3x3 matrix is the transform of the original matrix The inverse of the translation component is just the reverse translation.

20 Composition of Transforms
Various motions can be tacked, one after the other, in a long sequence of matrices: T1T2T3…T4 These combinations will maintain the relative shape of the vectors processed, but will shift them around the original coordinate frame.

21 Thinking of Reference Frames
Another way to think of this mathematics, is to imagine transforming the coordinate frame to a new place Transformation, T, moves things 5 to the right and 2 up. The whole coordinate frame moves to a new position z1 y1 z0 y0 T(5,0,2) x1 x0

22 Coordinate Rotation y0 y1 R(y=-35) z0 z1 x1 x0

23 The Matrix Stack While drawing a world, you often want to draw with respect to a convenient coordinate frame The graphics card need only keep track of the current position (current transformation) If you want to shift to the left, multiply the current frame by a left translation When done, shift back to the right

24 Learning Objectives Learn how 2D transformations are represented in 3D. Recognize the inverse matrix for a homogeneous transformation. Understand how the transformations also represent coordinate frame transformations. Understand the concept of a matrix stack.

25 Rendering: Transformations
So far, discussion has been in screen space But model is stored in model space (a.k.a. object space or world space) Three sets of geometric transformations: Modeling transforms Viewing transforms Projection transforms

26 Rendering: Transformations
Modeling transforms Size, place, scale, and rotate objects parts of the model w.r.t. each other Object coordinates  world coordinates Z X Y

27 Rendering: Transformations
Viewing transform Rotate & translate the world to lie directly in front of the camera Typically place camera at origin Typically looking down -Z axis World coordinates  view coordinates

28 Rendering: Transformations
Projection transform Apply perspective foreshortening Distant = small: the pinhole camera model View coordinates  screen coordinates

29 Rendering: Transformations
All these transformations involve shifting coordinate systems (i.e., basis sets) That’s what matrices do… Represent coordinates as vectors, transforms as matrices Multiply matrices = concatenate transforms!

30 Rendering: Transformations
Homogeneous coordinates: represent coordinates in 3 dimensions with a 4-vector Denoted [x, y, z, w] Note that typically w = 1 in model coordinates To get 3-D coordinates, divide by w: [x’, y’, z’] = [x/w, y/w, z/w] Transformations are 4x4 matrices Why? To handle translation, rotation and projection uniformly

31 Translations For convenience we usually describe objects in relation to their own coordinate system Solar system example We can translate or move points to a new position by adding offsets to their coordinates: Note that this translates all points uniformly

32  2-D Rotation (x’, y’) (x, y) x’ = x cos() - y sin()
y’ = x sin() + y cos() (Draw it)

33 2-D Rotations Rotations in 2-D are easy: 3-D is more complicated
Need to specify an axis of rotation Common pedagogy: express rotation about this axis as the composition of canonical rotations Canonical rotations: rotation about X-axis, Y-axis, Z-axis

34 3-D Rotations Basic idea: Objections:
Using rotations about X, Y, Z axes, rotate model until desired axis of rotation coincides with Z-axis Perform rotation in the X-Y plane (i.e., about Z-axis) Reverse the initial rotations to get back into the initial frame of reference Objections: Difficult & error prone Ambiguous: several combinations about the canonical axis give the same result

35 Scaling Scaling a coordinate means multiplying each of its components by a scalar Uniform scaling means this scalar is the same for all components:  2

36 Scaling Non-uniform scaling: different scalars per component:
How can we represent this in matrix form? X  2, Y  0.5

37 Scaling Scaling operation: Or, in matrix form: scaling matrix

38 2-D Rotation This is easy to capture in matrix form:
3-D is more complicated Need to specify an axis of rotation Simple cases: rotation about X, Y, Z axes

39 3-D Rotation What does the 3-D rotation matrix look like for a rotation about the Z-axis? Build it coordinate-by-coordinate

40 3-D Rotation What does the 3-D rotation matrix look like for a rotation about the Y-axis? Build it coordinate-by-coordinate

41 3-D Rotation What does the 3-D rotation matrix look like for a rotation about the X-axis? Build it coordinate-by-coordinate

42 Translation Matrices? We can composite scale matrices just as we did rotation matrices But how to represent translation as a matrix? Answer: with homogeneous coordinates

43 Homogeneous Coordinates
Homogeneous coordinates: represent coordinates in 3 dimensions with a 4-vector (Note that typically w = 1 in object coordinates)

44 Homogeneous Coordinates
Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4:

45 Homogeneous Coordinates
Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4:

46 Homogeneous Coordinates
Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4:

47 Homogeneous Coordinates
Homogeneous coordinates seem unintuitive, but they make graphics operations much easier Our transformation matrices are now 4x4:

48 Homogeneous Coordinates
How can we represent translation as a 4x4 matrix? A: Using the rightmost column:

49 The Rendering Pipeline: 3-D
Scene graph Object geometry Result: All vertices of scene in shared 3-D “world” coordinate system Vertices shaded according to lighting model Scene vertices in 3-D “view” or “camera” coordinate system Exactly those vertices & portions of polygons in view frustum 2-D screen coordinates of clipped vertices Modeling Transforms Lighting Calculations Viewing Transform Clipping Projection Transform

50 Rendering: Lighting Illuminating a scene: coloring pixels according to some approximation of lighting Global illumination: solves for lighting of the whole scene at once Local illumination: local approximation, typically lighting each polygon separately Interactive graphics (e.g., hardware) does only local illumination at run time

51 The Rendering Pipeline: 3-D
Scene graph Object geometry Result: All vertices of scene in shared 3-D “world” coordinate system Vertices shaded according to lighting model Scene vertices in 3-D “view” or “camera” coordinate system Exactly those vertices & portions of polygons in view frustum 2-D screen coordinates of clipped vertices Modeling Transforms Lighting Calculations Viewing Transform Clipping Projection Transform

52 Rendering: Clipping Clipping a 3-D primitive returns its intersection with the view frustum: See Foley & van Dam section 19.1

53 Rendering: Clipping Clipping is tricky! In: 3 vertices Out: 6 vertices
In: 1 polygon Out: 2 polygons Clip

54 The Rendering Pipeline: 3-D
Transform Illuminate Clip Project Rasterize Model & Camera Parameters Rendering Pipeline Framebuffer Display

55 Modeling: The Basics Common interactive 3-D primitives: points, lines, polygons (i.e., triangles) Organized into objects Collection of primitives, other objects Associated matrix for transformations Instancing: using same geometry for multiple objects 4 wheels on a car, 2 arms on a robot

56 Modeling: The Scene Graph
The scene graph captures transformations and object-object relationships in a DAG Objects in black; blue arrows indicate instancing and each have a matrix Robot Head Body Mouth Eye Leg Trunk Arm

57 Modeling: The Scene Graph
Traverse the scene graph in depth-first order, concatenating transformations Maintain a matrix stack of transformations Robot Visited Head Body Unvisited Mouth Eye Leg Trunk Arm Matrix Stack Active Foot

58 Modeling: The Camera Finally: need a model of the virtual camera
Can be very sophisticated Field of view, depth of field, distortion, chromatic aberration… Pinhole camera model Field of view Aspect ratio Near & far clipping planes Camera pose: position & orientation

59 Rigid-Body Transforms
Goal: object coordinatesworld coordinates Idea: use only transformations that preserve the shape of the object Rigid-body or Euclidean transforms Includes rotation, translation, and scale

60 Vectors and Matrices Vector algebra operations can be Dot product:
Cross product: Note: use right-hand rule!

61 3-D Rotation General rotations in 3-D require rotating about an arbitrary axis of rotation Deriving the rotation matrix for such a rotation directly is difficult Standard approach: express general rotation as composition of canonical rotations Rotations about X, Y, Z

62 Composing Canonical Rotations
Goal: rotate about arbitrary vector A by  Idea: we know how to rotate about X,Y,Z So, rotate about Y by  until A lies in the YZ plane, Then rotate about X by  until A coincides with +Z, Then rotate about Z by  Then reverse the rotation about X (by -) Then reverse the rotation about Y (by -)

63 Composing Canonical Rotations
First: rotating about Y by  until A lies in YZ How exactly do we calculate ? Project A onto XZ plane Find angle  to X:  = -(90° - ) =  - 90 ° Second: rotating about X by  until A lies on Z How do we calculate ?

64 3-D Rotation Matrices So an arbitrary rotation about A composites several canonical rotations together Compositing transforms == multiplying matrices express the final rotation as the product of canonical rotation a single matrix!

65 Compositing Matrices So we have the following matrices:
p: The point to be rotated about A by  Ry : Rotate about Y by  Rx  : Rotate about X by  Rz : Rotate about Z by  Rx  -1: Undo rotation about X by  Ry-1 : Undo rotation about Y by  In what order should we multiply them?

66 Compositing Matrices Short answer: the transformations, in order, are written from right to left In other words, the first matrix to affect the vector goes next to the vector, the second next to the first, etc. So in our case: p’ = Ry-1 Rx  -1 Rz Rx  Ry p

67 Rotation Matrices Notice these two matrices:
Rx  : Rotate about X by  Rx  -1: Undo rotation about X by  How can we calculate Rx  -1?

68 Rotation Matrices Notice these two matrices:
Rx  : Rotate about X by  Rx  -1: Undo rotation about X by  How can we calculate Rx  -1? Obvious answer: calculate Rx (-) Clever answer: exploit fact that rotation matrices are orthonormal

69 Rotation Matrices Notice these two matrices:
Rx  : Rotate about X by  Rx  -1: Undo rotation about X by  How can we calculate Rx  -1? Obvious answer: calculate Rx (-) Clever answer: exploit fact that rotation matrices are orthonormal What is an orthonormal matrix? What property are we talking about?

70 Rotation Matrices Orthonormal matrix:
orthogonal (columns/rows linearly independent) Columns/rows sum to 1 The inverse of an orthogonal matrix is just its transpose:

71 2D Vs. 3D 2 Dimensional (2D) objects have just a height and a width, for example a drawing of a rectangle on a sheet of paper. This can be described in terms of X & Y coordinates. 3 Dimensional (3D) objects have a height, width and depth, for example a cardboard box. These can be described in terms of X, Y & Z.

72 Vectors In computer graphics and mathematics, a Vector is just a term for Direction and Length. A vector can also describe a Displacement. A displacement is just a distance travelled in a certain direction. A vector (x,y,z) may be visualised as a line with one end tied to the origin and the other at (x,y,z) with an arrow at this point.

73 Vectors 2 A 3D vector has 3 degrees of freedom.
3 separate numbers are required to describe a 3D vector.

74 Vectors 3

75 Normal Vectors A Normal Vector is simply a vector that points at right angles to something else. Normally a surface in computer graphics.

76 Vector Operations Addition
The sum of two (or more) vectors is simply the sum of their displacements Vectors are summed by individually summing the X, Y & Z components Consider the following vector addition (-2,1,0) + (0,0,1) + (-1,-1,0) + (0,0,-1) = (-3,0,0) Simply adding the individual components of each, as you would add any number, provides the new vector (-3,0,0)

77 Vector Operations Scaling
Vector Scaling changes a vectors length by a Scale Factor. For example if the vector (2,0,0) is scaled by a factor of 3, it becomes (6,0,0) If the scale factor is a positive number, the vectors direction remains unchanged If the scale factor is a negative number, the vectors direction is flipped (180 degrees)

78 Vector Operations Note that the Vector labelled ? cannot be obtained by scaling the original vector, since its direction is not parallel

79 Vector Operations Norm of a vector
The norm of a vector gives its length (providing a metric for 3D space) The norm of a vector (x,y,z) gives us the distance from the origin to the point (x,y,z). Normalising a vector gives us a vector that has the same direction and length 1

80 Vector Operations Similarity of Direction
It is often useful to know how much two vectors are pointing in the same direction For example we may wish to know how much a surface is pointing toward a light source (when calculating illumination) This means we need to find the variation in direction between the vector from the surface to the light source, and the surface normal vector This will produce a number between 1 and –1 1 indicates that the vectors are directionally identical 0 indicates that the vectors are at right-angles -1 indicates that the vectors are pointing in exactly the opposite direction

81 Vector Operations Dot Product
Similarity of direction is more commonly referred to as the Vector Dot Product. The dot product of two normalised vectors is simply the length of the projection of one vector onto the other. This is illustrated in the following slide.

82 Vector Operations Dot Product
The dot product of two unit vectors is 1 when they point in the same direction, 0 when they are at right angles and -1 when they point in opposite directions

83 Vector Operations Cross Product
Cross product is an operation to find a vector that is perpendicular to two existing vectors You may need to do this to find the surface normal vector when you have two vectors pointing in different directions along the surface In computer graphics, it is generally the direction of the resulting cross product that is of interest In the example on the following slide, the yellow vector is the normalised cross product of the red and green vectors

84 Vector Operations Cross Product

85 3D Transforms Once an object has been modelled, it is frequently desirable to move, rotate or distort it. These modifications can be completed by the use of a 3D transform 3D transforms relate to the coordinate space

86 Coordinate Spaces Before points may be plotted within a 3D ( or 2D) space, the coordinate space must be defined Within a coordinate space there is one point where a axis cross, this is termed the origin For each axis starting at the origin, a vector is specified that will move +1 along that axis For a 3D space there are 3 vectors (one for each axis) representing X, Y & Z A vector that defines +1 along a given axis is termed a Basis Vector

87 Coordinate Spaces 2 The Red arrow represents the X axis, Green the Y axis and Blue the Z axis

88 Coordinate Spaces 3 This coordinate space definition is Relative not Absolute It is a way to define a new coordinate space relative to an existing one The origin and basis vectors need to be defined in a space. The origin of the new space is coordinates of a point in the old space It can be thought of as a vector from the original spaces origin to the new spaces origin Since this is the displacement of the new space from the old, this vector may be termed the Displacement Vector

89 Coordinate Space

90 Merging Transforms The 3rd space is defined in terms of the 2nd, which in turn in defined in terms of the 1st

91 Merging Transforms This is the same 3rd space as defined in the previous slide, this time derived directly from the 1st

92 Other Transforms Transforms can be used for many operations including translation, rotation, displacement and skewing The following slides show several transform operations applied to the figure below

93 Other Transforms Displacing the objects coordinate system to (0.6,0.5,0) from the original position

94 Other Transforms Displacing and Scaling. All 3 basis vectors are scaled by 1/2

95 Other Transforms Displacement and Non-uniform scaling. The Y basis is scaled by 2, while the Z basis is scaled by 1/2

96 Other Transforms Displacement and Rotation. The coordinate space is rotated 300 about the Z axis, and 100 degrees about the X


Download ppt "HCT."

Similar presentations


Ads by Google