CG Unit 2
CG Unit 2
Or
P’ = S . P
Where S is the scaling matrix.
Rotation
• It is a process of changing the angle of the object. Rotation can be
clockwise or anticlockwise. For rotation, we have to specify the angle of
rotation and rotation point.
• Rotation point is also called a pivot point. It is print about which object is
rotated.
• In rotation, we rotate the object at particular angle θ theta from its origin.
From the following figure, we can see that the point P(X,Y) is located at
angle φ from the horizontal X coordinate with distance r from the origin.
SOLUTION
1) Translate The Square So That Its Centre Coincide With The Origin
2) Scale The Square With Respect To Origin
3) Translate Back, The Square To Original Position
Rotation About an Arbitrary Point
• If we want to rotate an object or
point about an arbitrary point, first
of all, we translate the point about
which we want to rotate to the
origin.
• Then rotate point or object about
the origin, and at the end, we again
translate it to the original place.
• We get rotation about an arbitrary
point.
Rotation About an Arbitrary Point
• The composite rotation transformation matrix is
T2 R1 T1
• 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)
Scaling About an Arbitrary Point
Reflection about arbitrary line
1. Translate the line and the object so that the line passes through the origin
2. Rotate the line and the object about the origin until the line is coincident
with one of the coordinate axis
3. Reflect object through coordinate axis
4. Rotate back about the origin (Inverse Rotation)
5. Translate back to the original location (Inverse translation)
• [T] = [T]-1 [R]-1 [R’] [R] [T’]
• [T’]- Translation Matrix
• [R] - Rotation Matrix about the origin
• [R’]- Reflection Matrix
Window-to-viewport Coordinate
Transformation
• A world-coordinate area (finite) selected for display is called a
window.
• An area on a display device to which a window is mapped is called a
viewport.
• The window defines what is to be viewed; the viewport defines
where it is to be displayed.
• World coordinate – It is the Cartesian coordinate w.r.t which we
define the diagram, like Xwmin, Xwmax, Ywmin, Ywmax
• Device Coordinate –It is the screen coordinate where the objects are
to be displayed, like Xvmin, Xvmax, Yvmin, Yvmax
• Window –It is the area on the world coordinate selected for display.
• ViewPort –It is the area on the device coordinate where graphics is to
be displayed.
• A point at position (xw,yw) in a designated
window is mapped to viewport coordinates
(xv,yv). So that relative positions in the two areas
are the same.
• A point at position (xw,yw) in the window is
mapped into position (xv, yv) in the associated
viewport
• To maintain the same relative placement in the viewport as in the
window, we require that
• Solving these expressions for the viewport position (xv, yv), we have
• xv = xvmin + (xw - xwmin) sx
• yv = yvmin + (yw - ywmin) sy
• where the scaling factors are
sy
• This conversion is performed with the following sequence of
transformations:
1. Perform a scaling transformation using a fixed-point position of
(xwmin,ywmin) that scales the window area to the size of the viewport.
2. Translate the scaled window area to the position of the viewport.
• Relative proportions of objects are maintained if the scaling factors
are the same (sx = sy). Otherwise, world objects will be stretched or
contracted in either the x or y direction when displayed on the output
device.
3D Transformations
• In Computer graphics, Transformation is a process of modifying and re-positioning the existing
graphics.
• 3D Transformations take place in a three dimensional plane.
• 3D Transformations are important and a bit more complex than 2D Transformations.
• In very general terms a 3D model is a mathematical representation of a physical entity that
occupies space.
• In more practical terms, a 3D model is made of a description of its shape and a description of its
color appearance.
• 3D Transformation is the process of manipulating the view of a three-D object with respect to its
original position by modifying its physical attributes through various methods of transformation
like Translation, Scaling, Rotation, Shear, etc.
• Properties of 3-D Transformation:
• Lines are preserved,
• Parallelism is preserved,
• Proportional distances are preserved.
3D Translation
• 3D Translation is a process of moving an object from one position to
another in a three dimensional plane.
• Consider a point object O has to be moved from one position to another in
a 3D plane.
• Let-
• Initial coordinates of the object O = (Xold, Yold, Zold)
• New coordinates of the object O after translation = (Xnew, Ynew, Zold)
• Translation vector or Shift vector = (Tx, Ty, Tz)
• Given a Translation vector (Tx, Ty, Tz)-
• Tx defines the distance the Xold coordinate has to be moved.
• Ty defines the distance the Yold coordinate has to be moved.
• Tz defines the distance the Zold coordinate has to be moved.
• This translation is achieved by adding the
translation coordinates to the old
coordinates of the object as-
• Xnew = Xold + Tx (This denotes translation
towards X axis)
• Ynew = Yold + Ty (This denotes translation
towards Y axis)
• Znew = Zold + Tz (This denotes translation
towards Z axis)
• In Matrix form, the above translation equations may be represented
as-
• Given a 3D object with coordinate points A(0, 3, 1), B(3, 3, 2), C(3, 0,
0), D(0, 0, 0). Apply the translation with the distance 1 towards X axis,
1 towards Y axis and 2 towards Z axis and obtain the new coordinates
of the object.
3D Scaling
• Scaling is a process of modifying or altering the size of objects.
• Scaling may be used to increase or reduce the size of object.
• Scaling subjects the coordinate points of the original object to
change.
• Scaling factor determines whether the object size is to be increased
or reduced.
• If scaling factor > 1, then the object size is increased.
• If scaling factor < 1, then the object size is reduced.
• Consider a point object O has to be scaled in a 3D plane.
• Let-
• Initial coordinates of the object O = (Xold, Yold,Zold)
• Scaling factor for X-axis = Sx
• Scaling factor for Y-axis = Sy
• Scaling factor for Z-axis = Sz
• New coordinates of the object O after scaling = (Xnew, Ynew, Znew)
• This scaling is achieved by using the following scaling equations-
• Xnew = Xold x Sx
• Ynew = Yold x Sy
• Znew = Zold x Sz
• In Matrix form, the above scaling equations may be represented as-
• Given a 3D object with coordinate points A(0, 3, 3), B(3, 3, 6), C(3, 0,
1), D(0, 0, 0). Apply the scaling parameter 2 towards X axis, 3 towards
Y axis and 3 towards Z axis and obtain the new coordinates of the
object.
3D Rotation
• 3D Rotation is a process of rotating an object with respect to an angle in a three
dimensional plane.
• Consider a point object O has to be rotated from one angle to another in a 3D
plane.
• Let-
• Initial coordinates of the object O = (Xold, Yold, Zold)
• Initial angle of the object O with respect to origin = Φ
• Rotation angle = θ
• New coordinates of the object O after rotation = (Xnew, Ynew, Znew)
• In 3 dimensions, there are 3 possible types of rotation-
• X-axis Rotation
• Y-axis Rotation
• Z-axis Rotation
For X-Axis Rotation-
• This rotation is achieved by using the following rotation equations-
• Xnew = Xold
• Ynew = Yold x cosθ – Zold x sinθ
• Znew = Yold x sinθ + Zold x cosθ
• In Matrix form, the above rotation equations may be represented as-
For Y-Axis Rotation-
• This rotation is achieved by using the following rotation equations-
• Xnew = Zold x sinθ + Xold x cosθ
• Ynew = Yold
• Znew = Yold x cosθ – Xold x sinθ
• In Matrix form, the above rotation equations may be represented as-
For Z-Axis Rotation-
• This rotation is achieved by using the following rotation equations-
• Xnew = Xold x cosθ – Yold x sinθ
• Ynew = Xold x sinθ + Yold x cosθ
• Znew = Zold
• In Matrix form, the above rotation equations may be represented as-
• Given a homogeneous point (1, 2, 3). Apply rotation 90 degree
towards X, Y and Z axis and find out the new coordinate points.
3D Reflection
• Reflection is a kind of rotation where the angle of rotation is 180
degree.
• The reflected object is always formed on the other side of mirror.
• The size of reflected object is same as the size of original object.
• Consider a point object O has to be reflected in a 3D plane.
• Let-
• Initial coordinates of the object O = (Xold, Yold, Zold)
• New coordinates of the reflected object O after reflection = (Xnew, Ynew,Znew)
• In 3 dimensions, there are 3 possible types of reflection-
• Reflection relative to XY plane
• Reflection relative to YZ plane
• Reflection relative to XZ plane
Reflection Relative to XY Plane
• This reflection is achieved by using the following reflection equations-
• Xnew = Xold
• Ynew = Yold
• Znew = -Zold
• In Matrix form, the above reflection equations may be represented
as-
Reflection Relative to YZ Plane
• This reflection is achieved by using the following reflection equations-
• Xnew = -Xold
• Ynew = Yold
• Znew = Zold
• In Matrix form, the above reflection equations may be represented
as-
Reflection Relative to XZ Plane
• This reflection is achieved by using the following reflection equations-
• Xnew = Xold
• Ynew = -Yold
• Znew = Zold
• In Matrix form, the above reflection equations may be represented
as-
• Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4, 2),
C(5, 6, 3). Apply the reflection on the XY plane and find out the new
coordinates of the object.
3D Shearing
• 3D Shearing is an ideal technique to change the shape of an existing
object in a three dimensional plane.
• In a three dimensional plane, the object size can be changed along X
direction, Y direction as well as Z direction.
• So, there are three versions of shearing-
1. Shearing in X direction
2. Shearing in Y direction
3. Shearing in Z direction
• Consider a point object O has to be sheared in a 3D plane.
• Let-
• Initial coordinates of the object O = (Xold, Yold, Zold)
• Shearing parameter towards X direction = Shx
• Shearing parameter towards Y direction = Shy
• Shearing parameter towards Z direction = Shz
• New coordinates of the object O after shearing = (Xnew, Ynew, Znew)
Shearing in X Axis
• Shearing in X axis is achieved by using the following shearing
equations-
• Xnew = Xold
• Ynew = Yold + Shy x Xold
• Znew = Zold + Shz x Xold
• In Matrix form, the above shearing equations may be represented as-
Shearing in Y Axis
• Shearing in Y axis is achieved by using the following shearing
equations-
• Xnew = Xold + Shx x Yold
• Ynew = Yold
• Znew = Zold + Shz x Yold
• In Matrix form, the above shearing equations may be represented as-
Shearing in Z Axis
• Shearing in Z axis is achieved by using the following shearing
equations-
• Xnew = Xold + Shx x Zold
• Ynew = Yold + Shy x Zold
• Znew = Zold
• In Matrix form, the above shearing equations may be represented as-
• 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.
Rotation about an Arbitrary Axis in Space
• Rotation of a point in 3 dimensional space by theta about an arbitrary
axes defined by a line between two points P1 = (x1,y1,z1) and
P2 = (x2,y2,z2) can be achieved by the following steps
(1) translate space so that the rotation axis passes through the origin
(2) rotate space about the x axis so that the rotation axis lies in the xz plane
(3) rotate space about the y axis so that the rotation axis lies along the z axis
(4) perform the desired rotation by theta about the z axis
(5) apply the inverse of step (3)
(6) apply the inverse of step (2)
(7) apply the inverse of step (1)
Demonstration of Rotation about an Arbitrary
Axis in Space
• https://youtu.be/75o5pmeXUMo?si=QzmKQv1jyza7x-Jr
Reflection through an arbitrary plane
• It is often necessary to reflect an object through an arbitrary plane
other than one of the coordinate planes like x = 0, y = 0 and z = 0.
• The basic idea is to make the arbitrary reflection plane coincide with
one of the coordinate planes.
• Assuming an arbitrary plane in space is given by three points P0 (x0,
y0, z0), P1 (x1, y1, z1) and P2 (x2, y2, z2), these points are
non-collinear.
• According to the previous section one possible procedure is:
1. Translate the reflection plane to the origin of the coordinate system with the
help of known P0 (x0, y0, z0) point.
2. Perform appropriate rotations to make the normal vector of the reflection
plane at the origin until it coincides with the +z-axis this makes the reflection
plane the z = 0 coordinate plane.
3. After that reflect the object through the z = 0 coordinate plane.
4. Perform the inverse of the combined rotation transformation in step 2.
5. Perform the inverse of the translation in step 1.
Composition of 3D Transformations
• A number of transformations or sequence of transformations can be
combined into single one called as composition. The resulting matrix
is called as composite matrix. The process of combining is called as
concatenation.
• Suppose we want to perform rotation about an arbitrary point, then
we can perform it by the sequence of three transformations
• Translation
• Rotation
Affine Transformation
• Affine transformation is a linear mapping method that preserves points,
straight lines, and planes. Sets of parallel lines remain parallel after an
affine transformation.
• The affine transformation technique is typically used to correct
for geometric distortions or deformations that occur with non-ideal camera
angles.
• For example, satellite imagery uses affine transformations to correct for
wide angle lens distortion, panorama stitching, and image registration.
• Transforming and fusing the images to a large, flat coordinate system is
desirable to eliminate distortion. This enables easier interactions and
calculations that don’t require accounting for image distortion.
The 3D synthetic camera model
• The synthetic camera model involves two components, specified
independently:
• objects (a.k.a. geometry)
• viewer (a.k.a. camera)
• The image is rendered onto an image plane or projection plane
(usually in front of the camera).
• Projectors emanate from the center of projection (COP) at the center
of the lens (or pinhole).
• The COP is the center of the lens or eye, or in computer graphics the
origin of the camera frame.
• Camera specification requires four kinds of
parameters:
• Position: the COP.
• Orientation: rotations about axes with origin at the
COP.
• Focal length: determines the size of the image on
the film plane, or the field of view.
• Film plane: its width and height, and possibly
orientation.
Projections
• Representing an n-dimensional object into an n-1 dimension is known as
projection.
• It is process of converting a 3D object into 2D object, we represent a 3D
object on a 2D plane {(x,y,z)->(x,y)}.
• It is also defined as mapping or transforming of the object in projection
plane or view plane.
• When geometric objects are formed by the intersection of lines with a
plane, the plane is called the projection plane and the lines are called
projections.
• Types of Projections:
• Parallel projections
• Perspective projections
Centre of Projection:
• It is an arbitrary point from where
the lines are drawn on each point
of an object.
• Also known as perspective
reference point.
• If cop is located at a finite point in
3D space , Perspective projection
is the result
• If the cop is located at infinity, all
the lines are parallel and the
result is a parallel projection.
Perspective Projections
• A perspective projection is the one produced by straight lines
radiating from a common point and passing through point on the
sphere to the plane of projection.
• Perspective projection is a geometric technique used to produce a
three dimensional graphic image on a plane, corresponding to what
person sees.
• In perspective projection farther away object from the viewer, small
it appears. This property of projection gives an idea about depth.
• The artist use perspective projection from drawing three-dimensional
scenes.
• The distance and angles are not preserved and parallel lines do not remain
parallel. Instead, they all converge at a single point called center of
projection.
• Two characteristic of perspective are vanishing point and perspective fore
shortening.
• Due to fore shortening objects and lengths appear smaller from the center
of projections. The projections are not parallel and we specify a center of
projection cop.
• Vanishing point is the point where all lines will appear to meet. There can
be one point, two point, and three point perspectives.
• View plane: It is an area of world coordinate system which is projected into
viewing plane.
• Center of Projection: It is the location of the eye on which projected light rays
converge.
• Projectors: It is also called a projection vector. These are rays start from the
object scene and are used to create an image of the object on viewing or view
plane.
• The volume of space that is actually rendered into the image is called the view
volume. Things inside the view volume make it into the image; things that are not
in the view volume are clipped and cannot be seen.
• Perspective drawings are often classified by the number of principal
vanishing points.
1. One-point perspective — In this, principal axis has a finite vanishing point.
Perspective projection is simple to draw.
2. Two-point perspective — Exactly 2 principals have vanishing points.
Perspective projection gives better impression of depth.
3. Three-point perspective — All the three principal axes have finite vanishing
point. Perspective projection is most difficult to draw.
Parallel Projection
• A parallel projection is formed by extending parallel lines from each vertex
of object until they intersect plane of screen.
• Parallel projection transforms object to the view plane along parallel lines.
• A projection is said to be parallel, if center of projection is at an infinite
distance from the projected plane.
• A parallel projection preserves relative proportion of objects, accurate
views of the various sides of an object are obtained with a parallel
projection.
• The projection lines are parallel to each other and extended from the
object and intersect the view plane.
• It preserves relative propositions of objects, and it is used in drafting to
produce scale drawings of 3D objects.
• This is not a realistic representation, the point of intersection is the
projection of the vertex.
• Perspective projections pros and cons:
+ Size varies inversely with distance - looks realistic
– Distance and angles are not (in general) preserved
– Projection lines do not (in general) remain parallel
• Parallel projection pros and cons:
– Less realistic looking
+ Good for exact measurements
+ Projection lines remain parallel
– Angles not (in general) preserved
• Parallel projection is further divided into two categories :
a) Orthographic Projection
b) Oblique Projection
Orthographic Projection
• It is a kind of parallel projection where the projecting lines emerge
parallelly from the object surface and incident perpendicularly at the
projecting plane.
Orthographic Multiview Projection
• There are three types :
1. Front Projection - In this orthographic
projection front face view of the object is
observed.
2. Top Projection - In this projection, the rays
that emerge from the top of the polygon
surface are observed.
3. Side Projection - It is another type of
projection orthographic projection where
the side view of the polygon surface is
observed.