Chapter 3 2D and 3D
Chapter 3 2D and 3D
The orientation, size, and shape of the output primitives are accomplished
with geometric transformations that alter the coordinate descriptions of objects.
The basic geometric transformations are translation, rotation, and scaling.
Other transformations that are often applied to objects include reflection and shear.
In these all cases we consider the reference point is origin so if we have to do these
transformations about any point then we have to shift these point to the origin first
and then perform required operation and then again shift to that position.
Basic Transformations:
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shearing
Homogenous Form:
We may have to perform more than one transformation in same object like scaling
the object, then rotate the same object, and finally translation. For this, first co-
ordinate positions are scaled, then this scaled co-ordinates are rotated and finally
translated. A more efficient approach would be to combine the transformation so
that final positions are obtained directly from initial co-ordinates thereby
eliminating the calculation of intermediate co-ordinates. This allows us to represent
all geometric transformation as matrix multiplication.
Expressing position in homogeneous coordinates allows us to represent all
geometric transformations equation as matrix multiplications.
We represent each Cartesian co-ordinate position (x, y) with homogenous triple co-
ordinate (xh, yh, h)
Translation:
A translation is applied to an object by repositioning it along a straight-line path
from one coordinate location to another. We translate a two-dimensional point by
adding translation distances, tx, and ty, to the original coordinate position (x, y) to
move the point to a new position (x ' , y').
Every point on the object is translated by the same amount
Rotation:
A two-dimensional rotation is applied to an object by repositioning it along a
circular path in the xy plane. To generate a rotation, we specify a rotation angle θ
and the position (xr, yr) of the rotation point (or pivot point) about which the object
is to be rotated.
+ Value for „θ‟ define counter-clockwise rotation about a point
-Value for „θ‟ defines clockwise rotation about a point
At origin
Clockwise direction:
Rotation of a point (x, y) about any point (xr, yr) / Fixed Point Rotation:
Steps
1. Translate object so as to coincide pivot to origin
2. Rotate object about the origin
3. Translate object back so as to return pivot to original position
Q1. Rotate the triangle (5, 5), (7, 3), (3, 3) in counter clockwise (CCW) by 90
degree.
Answer:
Q2. Rotate the triangle (5, 5), (7, 3), (3, 3) about fixed point (5, 4) in counter
clockwise (CCW) by 90 degree.
Solution:
Here, the required steps are:
1. Translate the fixed point to origin.
2. Rotate about the origin by specified angle θ.
3. Reverse the translation as performed earlier.
Scaling:
A scaling transformation alters the size of an object. This operation can be carried
out for polygons by multiplying the coordinate values (x, y) of each vertex by
scaling factors sx and sy to produce the transformed coordinates (x', y').
sx scales object in „x‟ direction
sy scales object in „y‟ direction
Reflection:
A reflection is a transformation that produces a mirror image of an object. The
mirror image for a 2D reflection is generated relative to an axis of reflection by
rotating the object 180" about the reflection axis. We can choose an axis of
reflection in the xy-plane or perpendicular to the xy plane. When the reflection axis
is a line in the xy plane, the rotation path about this axis is in a plane perpendicular
to the xy-plane. For reflection axes that are perpendicular to the xy-plane, the
rotation path is in the xy plane.
i. Reflection about x axis or about line y = 0
Q1. Reflect an object (2, 3), (4, 3), (4, 5) about line y = x +1.
Q2. A mirror is placed such that it passes through (0, 10), (10, 0). Fin the mirror
image of an object (6, 7), (7, 6), (6, 9).
Shearing:
It distorts the shape of object in either „x‟ or „y‟ or both direction. In case of
single directional shearing (e.g. in „x‟ direction can be viewed as an object made
up of very thin layer and slid over each other with the base remaining where it is).
Shearing is a non-rigid-body transformation that moves objects with deformation.
Shearing factor (Shx, Shy)
Composite Transformations:
Translation:
Rotation:
Scaling:
Two‐dimensional viewing:
Two-dimensional viewing is the mechanism for displaying views of a picture on an
output device. Much like what we see in real life through a small window on the
wall or the viewfinder of a camera, a computer-generated image often depicts a
partial view of a large scene. For a 2-D picture, a view is selected by specifying a
subarea of the total picture area.
Modeling Coordinates:
Modeling coordinates are used to construct shape of individual parts (objects or
structures) of a 2D scene. For example, generating a circle at the origin with a
“radius” of 2 units. Here, origin (0, 0), and radius 2 units are modeling coordinates.
Modeling coordinates define object shape. Can be floating-point, integers and can
represent units like km, m, miles, feet etc.
World Coordinates:
World coordinates are used to organize the individual parts into a scene.
World coordinates units define overall scene to be modeled.
World coordinates represent relative positions of objects. Can be floating-
point, integers and can represent units like km, m, miles etc.
Viewing Coordinates:
Viewing coordinates are used to define particular view of the user. Viewer‟s
position and view angle i.e. rotated/translated.
Viewing coordinates specify the portion of the output device that is to be
used to present the view.
Normalized viewing coordinates are viewing coordinates between 0 and 1 in
each direction. They are used to make the viewing process independent of
the output device (paper, mobile).
Window:
A world-coordinate area selected for display is called a window or clipping
window. That is, window is the section of the 2D scene that is selected for
viewing.
The window defines what is to be viewed.
Viewport:
An area on a display device to which a window is mapped is called a
viewport.
The viewport indicates where on an output device selected part will be
displayed.
1. Translate the window to the origin. That is, apply T (-Xwmin, -Ywmin)
2. Scale it to the size of the viewport. That is, apply S (Sx, Sy)
3. Translate scaled window to the position of the viewport. That is, apply T (Xvmin,
Yvmin).
Therefore, net transformation, TWV = T (Xvmin, Yvmin). S(Sx, Sy).T(-Xwmin, -Ywmin)
It maintains the same relative placement of objects in normalized space as in
viewing coordinates.
Let (x, y) be the world coordinate point that is mapped onto the viewport point (u,
v), then we must have
Three‐Dimensional Graphics:
Three-dimensional space is a geometric 3-parameters model of the physical
universe (without considering time) in which all known matter exists. These three
dimensions can be labeled by a combination of length, breadth, and depth. Any
three directions can be chosen, provided that they do not all lie in the same plane.
An object that has height, width and depth, like any object in the real world is a 3
dimensional object.
3D Transformations:
Just as 2D-transfromtion can be represented by 3x3 matrices using homogeneous
co-ordinate can be represented by 4x4 matrices,
provided we use homogenous co-ordinate
representation of points in 3D space as well.
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
Translation:
Translation in 3D is similar to translation in the 2D except that there is one more
direction parallel to the z-axis. If, tx, ty, and tz are used to represent the translation
vectors. Then the translation of the position P(x, y, z) into the point P' (x', y', z') is
done by:
Scaling:
Reflection
Shear:
Shearing transformations can be used to modify object shapes.
Z-axis Shear
This transformation alters x- and y-coordinate values by an amount that is
proportional to the z value, while leaving the z coordinate unchanged, i.e.
Q. Given a 3D triangle with points (0, 0, 0), (1, 1, 2) and (1, 1, 3). Apply shear
parameter 2 on X axis, 2 on Y axis and 3 on Z axis and find out the new
coordinates of the object.
Solution:
Shearing in X Axis-
For Coordinates A(0, 0, 0)
Let the new coordinates of corner A after shearing = (Xnew, Ynew, Znew).
3D Viewing Pipeline:
The viewing-pipeline in 3 dimensions is almost the same as the 2D viewing-
pipeline. Only after the definition of the viewing direction and orientation (i.e., of
the camera) an additional projection step is done, which is the reduction of 3D-data
onto a projection plane:
World to screen viewing transformation:
But in 3D graphics application, we have to consider spatial position (i.e. an object
can be viewed from the front, from above or form the back) or we could generate a
view of what we would see if we were standing in the middle of a group of objects
or inside a single object, such as buildings.
The steps for computer generation of a view of a three dimensional scene are
analogous to the process involved in taking a photograph.
To take a snapshot, we first need to position the camera at a particular point
in space, then need to decide on the camera orientation. (i.e. which way do
we point the camera and how should we rotate it around the line of sight to
set the up direction for the picture). Finally, when we snap the shutter, the
scene is cropped to the size of the shutter, the scene is cropped to the size of
the „window‟ (aperture) of the camera and light from the visible surface is
projected.
Each model or object has its own dimension and coordinate system. It is
called modeling coordinate. Modeling transformation is to take all the
objects in a single scene by using transformation such translation, rotation
etc. To set object is called modeling translation.
After modeling translation, the objects come to scene or a coordinate system
is called world coordinate.
To set the camera on some position, angle or orientation is called viewing
transformation. From viewing transformation we get viewing coordinate.
Projection transformation is to adjust focus, zoom in, zoom out etc.
Projection transformation creates projection coordinates.
Workstation or viewport translation is just like to click the button to save the
image in the device.
Once the scene has been modeled, world coordinate positions are converted
to viewing co-ordinate.
The VC system is used in graphics system as a reference for specifying the
observer viewing position and the position of the projection plane analogous
to camera film plane.
Projection operations are performed to convert VC description of a scene to
co-ordinate positions on the projection plane.
The projection plane is then mapped to output device.
World to screen viewing transformation:
Suppose that the viewing co-ordinates are specified in world co-ordinates. We
need to transform each vertex specified in world co-ordinates to view co-ordinates.
1. Translate world co-ordinate origin to viewing co-ordinates origin.
2. Apply rotation to align u, v and n with the world x, y and z.
Transformation Matrices:
Translation:
If the view reference point is specified at world position(x0, y0, z0) this point is
translated to world origin with the matrix
transformation.
Rotation
The composite rotation matrix for viewing
transformation is then
Projection:
Projection:
Transformation that changes a point in n-dimensional coordinate system into
a point in a coordinate system that has dimension less than n.
Converts 3-D viewing co-ordinates to 2-D projection coordinates
View Plane or Projection Plane: Two dimensional plane in which 3D objects
are projected is called the view plane or projection plane. Simply it is a
display plane on an output device
Types of Projection
Vanishing Point:
A set of parallel lines that are not parallel to the view plane pare projected as
converging lines that appear to converge at a point called vanishing point.
A set of parallel lines that are parallel to view plane are projected as parallel
lines.
More than one set of parallel lines form more than
one vanishing point in the scene.
Perspective Projection:
Let dp = Zprp –Zvp, which is the difference between COP and view plane distances
then, we can form a matrix as
And original z co-ordinate value would be retained for visible surface and other
depth processing.