Download presentation
Published byAntonia Heath Modified over 9 years ago
1
Introduction to Computer Graphics Geometric Transformations
EEL Introduction to Computer Graphics Geometric Transformations By Kiranmayi Karri U
2
Outline Transformation Geometric Transformation 2D Transformation
References
3
Transformation What is a transformation?
An operation that changes one configuration into another. A geometric transformation maps positions that define the object to other positions Linear transformation means the transformation is defined by a linear function. Why use them? Modeling Moving the objects to the desired location in the environment Multiple instances of a prototype shape
4
Geometric Transformation
In computer graphics many applications need to alter or manipulate a picture, for example, by changing its size, position or orientation. This can be done by applying a geometric transformation to the coordinate points defining the picture. Once the models are prepared, we need to place them in the environment .Objects are defined in their own local coordinate system .We need to translate, rotate and scale them to put them into the world coordinate system .
5
Types of Transformations
Geometric Transformations Translation Rotation Scaling Linear Transformation Non-uniform scales, shears or skews Non-linear Transformation • Twists, bends, warps, morphs
6
2-D Transformations Translation A common requirement is to move a picture to a new position. Translation transform simply moves every point by a certain amount horizontally and a certain amount vertically. The original object and its translation have the same shape and size, and they face in the same direction.
7
2D Translation-Matrix Notation
A translation moves all points in an object along the same straight-line path to new positions. The path is represented by a vector, called the translation or shift vector. We can write the components: p'x = px + tx p'y = py + ty or in matrix form: P' = P + T
8
Rotation 2-D Transformations
A rotation is a transformation that turns a figure about a fixed point called the center of rotation. An object and its rotation are the same shape and size, but the figures may be turned in different directions. Another common type of transformation is rotation. This is used to orientate objects. A rotation transform, rotates each point about the origin, (0,0). Every point is rotated through the same angle, called the angle of rotation. For this purpose, angles can be measured either in degrees or in radians. A rotation with a positive angle rotates points in the direction from the positive x-axis to the positive y-axis.
9
2D Rotation – Matrix Notation
A rotation repositions all points in an object along a circular path in the plane centered at the pivot point.
10
Scaling 2-D Transformations
Changing the size of an object is called a scale. We scale an object by scaling the x and y coordinates of each vertex in the object. We have two types of scaling, Uniform and Non-Uniform Scaling Uniform Scaling Uniform scaling is a linear transformation that enlarges or shrinks objects by a scale factor that is the same in all directions. The result of uniform scaling is similar to the original. Uniform scaling happens, for example, when enlarging or reducing a photograph, or when creating a scale model of a building, car, airplane, etc.
11
Scaling 2-D Transformations
Non Uniform Scaling Is obtained when at least one of the scaling factors is different from the others; a special case is directional scaling or stretching. Non-uniform scaling changes the shape of the object; e.g. a square may change into a rectangle, or into a parallelogram if the sides of the square are not parallel to the scaling axes (the angles between lines parallel to the axes are preserved, but not all angles). It occurs, for example, when a faraway billboard is viewed from an oblique angle, or when the shadow of a flat object falls on a surface that is not parallel to it.
12
2D Scaling-Matrix Notation
13
Homogeneous Coordinates
Homogeneous coordinates are a way to handle projective geometric spaces easily. These are non-Euclidean geometries that represent non-linear projections, like a perspective projection. Now, they also use an extra coordinate. The transformation between a Cartesian coordinate system and a Homogeneous one is done by dividing all of the components of the Homogeneous coordinates by the last coordinate.
14
Homogenous Coordinates
In Euclidean space (geometry), two parallel lines on the same plane cannot intersect, or cannot meet each other forever. It is a common sense that everyone is familiar with. However, it is not true any more in projective space. Euclidean space (or Cartesian space) describe our 2D/3D geometry so well, but they are not sufficient to handle the projective space (Actually, Euclidean geometry is a subset of projective geometry). The Cartesian coordinates of a 2D point can be expressed as (x, y). What if this point goes far away to infinity? The point at infinity would be (∞,∞), and it becomes meaningless in Euclidean space. The parallel lines should meet at infinity in projective space, but cannot do in Euclidean space. Solution to the problem of Euclidean Space is Homogeneous Coordinates Homogeneous coordinates, introduced by August Ferdinand Möbius, make calculations of graphics and geometry possible in projective space. Homogeneous coordinates are a way of representing N-dimensional coordinates with N+1 numbers. To make 2D Homogeneous coordinates, we simply add an additional variable, w, into existing coordinates. Therefore, a point in Cartesian coordinates, (X, Y) becomes (x, y, w) in Homogeneous coordinates. And X and Yin Cartesian are re-expressed with x, y and w in Homogeneous as; X = x/w Y = y/w For instance, a point in Cartesian (1, 2) becomes (1, 2, 1) in Homogeneous. If a point, (1, 2), moves toward infinity, it becomes (∞,∞) in Cartesian coordinates. And it becomes (1, 2, 0) in Homogeneous coordinates, because of (1/0, 2/0) = (∞,∞). Notice that we can express the point at infinity without using "∞".
15
Inverse Transformations
16
Composite 2-D Transformations
We can represent any sequence of transformations as a single matrix. No special cases when transforming a point – matrix * vector. Composite transformations – matrix * matrix. Composite transformations: Rotate about an arbitrary point – translate, rotate, translate Scale about an arbitrary point – translate, scale, translate Change coordinate systems – translate, rotate, scale
17
Composite Transformation
Transformation T followed by Transformation Q followed by Transformation R
18
Order of Composite transformation
In composite transformations, the order of transformations is very important. Rotation followed by Translation: Translation followed by Rotation:
19
Rotation wrt x-axis and y-axis
To rotate about an arbitrary point P (px,py) by θ: Translate the object so that P will coincide with the origin: T(-px, -py) Rotate the object: R(θ) Translate the object back: T(px,py) . Translate the object so that P will coincide with the origin: T(-px, -py) Rotate the object: R(θ) Translate the object back: T(px,py)
20
Rotation wrt. Arbitrary point
To rotate about P1 (x1,y1), the following sequence of the fundamental transformations are needed: 1.Translate the object by (-x1, -y1) 2.Rotate (Ø) 3.Translate the object by (x1, y1) The matrix representation of these steps is
21
Scaling wrt. Arbitrary point
To scale about P1 (x1,y1), the following sequence of the fundamental transformations is needed 1.Translate the object by (-x1, -y1) 2.Scale by (Sx, Sy) 3.Translate the object by (x1, y1) This series of steps can be performed as following:
22
Composite transformation order
In a composite transformation, the order of the individual transformations is very important. Matrix operations are not cumulative. For example, the result of a Graphics → Rotate → Translate → Scale → Graphics operation will be different from the result of a Graphics → Scale → Rotate → Translate → Graphics operation. The main reason that order is significant is that transformations like rotation and scaling are done with respect to the origin of the coordinate system. The result of scaling an object that is centered at the origin is different from the result of scaling an object that has been moved away from the origin. Similarly, the result of rotating an object that is centered at the origin is different from the result of rotating an object that has been moved away from the origin. Scale → Rotate → Translate composite transformation
23
Composite transformation order
Translate → Rotate → Scale composite transformation with Append Translate → Rotate → Scale composite transformation with Prepend
24
Rigid Motion A rigid motion is the action of taking an object and moving it to a different location without altering its shape or size. Reflections, rotations, translations, and glide reflections are all examples of rigid motions. In fact, every rigid motion is one of these four kinds.
25
Rigid Motion Reflection
Every reflection is completely determined by its axis of reflection. 2. Every reflection is completely determined by a single point-image pair P and P 0 (provided that P 6= P 0 ). 3. The fixed points of a reflection are exactly the points on its axis of reflection. 4. Reflections are improper rigid motions (they reverse clockwise and counterclockwise orientations). 5. Applying the same reflection twice gives the identity motion.
26
Rigid Motion Rotation Every rotation is completely determined by its rotocenter and the angle of rotation. 2. A 360◦ rotation is equivalent to the identity motion. (So are720◦ , 1040◦ , ) 3. A rotation that is not the identity has exactly one fixed point: the rotocenter. 4. Rotations are proper rigid motions (they preserve clockwise/counterclockwise orientations). 5. A rotation is determined by any two point-image pairs P, P 0 and Q, Q 0
27
Rigid Motion Translation
1. Every translation is completely determined by a vector of translation, v. 2. In a translation other than the identity, every point gets moved, so there are no fixed points. 3. Translations are proper rigid motions (they preserve clockwise/counterclockwise orientations). 4. A translation is determined by any one point-image pair P, P The effect of a translation can be reversed by a translation in the opposite direction (with vector −v).
28
Reflections Reflection is nothing more than a rotation of the object by 180o. In case of reflection the image formed is on the opposite side of the reflective medium with the same size. Therefore we use the identity matrix with positive and negative signs according to the situation respectively.
29
Reflections
30
Reflections
31
Reflections wrt to an arbitrary axis
32
Shear in x and y -direction
A shear along the x direction in 2D changes a rectangle (with lower right corner at the origin) into a parallelogram as follows The transformation has the properties: a) The y coordinate of any point (x,y) is unchanged b) the x coordinate is stretched in a linear way, based on the height of the point above the x axis - i.e. on y. Thus the coordinate change has the form: x' = x + ay y' = y where a is a constant that measures the degree of shearing. If a is negative then the shearing is in the opposite direction.
33
Matrix Notation A suitable multiplicative matrix description of the transform is given by: SHx(a) = | 1 a 0 | | | | | We can similarly introduce a shearing along the y axis, which would have the form: x' = x y' = y + bx and in this case a suitable matrix description is given by: SHy(b) = | | | b 1 0 |
34
Raster Methods Raster Graphics
Image is represented as a rectangular grid of colored pixels PIXEL = Pictu(X)re ELement Translation If you want to move a point (x0 , y0) to a new position (xt , yt) The transformation would be xt = x0 + dx and yt = y0 + dy For motion dx and dy are the components of the velocity vector dx = cos v and dy = - sin v
35
Raster Methods Scaling Rotation
Multiply the coordinates of each vertex by the scale factor Everything will expand from the center The transformation would be xt = x0 * scale and yt = y0 * scale Rotation Spin and object around it centered around the z-axis Rotate each point the same angle Positive angles are clockwise Negative angles are counterclockwise C++ uses radians (not degrees) xt = x0 * cos() – y0 * sin() yt = y0 * cos() + x0 * sin()
36
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
We will still use column vectors to represent points Homogeneous coordinates of a 3D point (x,y,z,1) Transformation will be performed using 4x4 matrix
37
Homogenous coordinates
3D Translation Very similar to 2D transformation Translation transformation Homogenous coordinates
38
Homogenous coordinates
3D Scaling Very similar to 2D transformation Scaling transformation Homogenous coordinates
39
3D Rotation 3D rotation is done around a rotation axis
Fundamental rotations – rotate about x, y, or z axes Counter-clockwise rotation is referred to as positive rotation (when you look down negative axis)
40
3D Rotation wrt z-axis Rotation about z – similar to 2D rotation y + x
41
3D Rotation wrt y-axis Rotation about y: z -> y, y -> x, x->z
42
3D Rotation wrt x-axis Rotation about x (z -> x, y -> z, x->y) x z y Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters, y x z
43
3D Rotation about Arbitrary Axes
Rotate p about the by the angle Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters, 43
44
Inverse of 3D Transformations
Invert the transformation In general, X= AX’->x’=A-1X T(-tx,-ty,-tz) T(tx,ty,tz)
45
3D Rotation about Arbitrary Axes
Rotate p about the by the angle Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters,
46
3D Rotation about Arbitrary Axes
Translate so that rotation axis passes through the origin Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters,
47
3D Rotation about Arbitrary Axes
Rotation by about z-axis Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters,
48
3D Rotation about Arbitrary Axes
Rotation by about y-axis Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters,
49
3D Rotation about Arbitrary Axes
Rotation by about z-axis Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters,
50
3D Rotation about Arbitrary Axes
Rotation by about y-axis Transformation equations for rotations about the other two coordinate axes can be obtained with a cyclic permutation of the coordinate parameters,
51
3D Rotation about Arbitrary Axes
Translate the object back to original point
52
3D Shearing
53
3D Reflection
54
3D Reflection Transformation
55
Affine Transformation
56
3D Coordinate Transformation
Transform object description from to p
57
3D Coordinate Transformation
Transform object description from to p
58
3D Coordinate Transformation
Transform object description from to p
59
3D Coordinate Transformation
Transform object description from to y x z
60
Composite 3D Transformation
Similarly, we can easily extend composite transformation from 2D to 3D
61
Composite 3D Transformation
62
References
63
References
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.