Professional Documents
Culture Documents
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Scaling
To change the size of an object, scaling transformation is used. In the scaling
process, you either expand or compress the dimensions of the object. Scaling can
be achieved by multiplying the original coordinates of the object with the scaling
factor to get the desired result.
Let us assume that the original coordinates are X,YX,Y, the scaling factors are
(SX, SY), and the produced coordinates are X′,Y′X′,Y′. This can be mathematically
represented as shown below −
X' = X . SX and Y' = Y . SY
The scaling factor SX, SY scales the object in X and Y direction respectively. The
above equations can also be represented in matrix form as below −
OR
P’ = P . S
Where S is the scaling matrix. The scaling process is shown in the following
figure.
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
If we provide values less than 1 to the scaling factor S, then we can reduce the
size of the object. If we provide values greater than 1, then we can increase the
size of the object.
Reflection
Reflection is the mirror image of original object. In other words, we can say that it
is a rotation operation with 180°. In reflection transformation, the size of the
object does not change.
The following figures show reflections with respect to X and Y axes, and about
the origin respectively.
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Shear
A transformation that slants the shape of an object is called the shear
transformation. There are two shear transformations X-Shear and Y-Shear. One
shifts X coordinates values and other shifts Y coordinate values. However; in both
the cases only one coordinate changes its coordinates and other preserves its
values. Shearing is also termed as Skewing.
X-Shear
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
The X-Shear preserves the Y coordinate and changes are made to X coordinates,
which causes the vertical lines to tilt right or left as shown in below figure.
Y-Shear
The Y-Shear preserves the X coordinates and changes the Y coordinates which
causes the horizontal lines to transform into lines which slopes up or down as
shown in the following figure.
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Composite Transformation
If a transformation of the plane T1 is followed by a second plane transformation
T2, then the result itself may be represented by a single transformation T which is
the composition of T1 and T2 taken in that order. This is written as T = T1∙T2.
Composite transformation can be achieved by concatenation of transformation
matrices to obtain a combined transformation matrix.
A combined matrix −
[T][X] = [X] [T1] [T2] [T3] [T4] …. [Tn]
Where [Ti] is any combination of
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Translation
Scaling
Shearing
Rotation
Reflection
The change in the order of transformation would lead to different results, as in
general matrix multiplication is not cumulative, that is [A] . [B] ≠ [B] . [A] and
the order of multiplication. The basic purpose of composing transformations is to
gain efficiency by applying a single composed transformation to a point, rather
than applying a series of transformation, one after another.
For example, to rotate an object about an arbitrary point (X p, Yp), we have to carry
out three steps −
Viewing Pipeline
Window – world coordinate area for display
Viewport – area on display device to which window is mapped
Window – what is viewed
Viewport – where it is displayed
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
2D Viewing-Transformation Pipeline
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Window-Viewport Mapping
Ywh-
Xwh Xwl Ywh Ywl Xwh-Xwl Ywl
7.5 2.5 9 2.5 5 6.5
Xvh Xvl Yvh Yvl Xvh-Xvl Yvh-Yvl
900 400 700 400 500 300
Y-
No. x y X-Viewport Viewport
1 1.0 4.0 250.000 469.231
2 4.0 10.0 550.000 746.154
3 8.0 8.0 950.000 653.846
4 8.0 4.0 950.000 469.231
1 1.0 4.0 250.000 469.231
Window
Coordinates Viewport Coordinates
x y x y
Window/Viewpo
2.5 2.5 400 400rt
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Clipping Operations
Clipping Algorithms -> procedure that identifies portions of picture either inside
or outside specified regions
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Applications of Clipping:
· Two Approaches:
1. Clip word coordinates -> only contents of window interior mapped to device
coordinates
2. Map all world coordinates to device coordinates -> then clip against
viewport boundaries
· Raster systems -> clipping part of scan conversion
Point Clipping
Rectangular clipping window…
Line Clipping
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Inside-Outside Test
· Check both endpoints -> if both P1 and P2 are within boundaries – line is
saved
· The bit is set depending on the location of the endpoint with respect to that
window component as shown below:
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Example:
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
§ Procedure:
o Begin with P1 and lower boundary and check against left, right, and
bottom boundaries
o Find intersection point P1’ with bottom boundary and replace P1 with
P1’
o Do same with P2 but we find two intersections p2’ and p2’’
o P2’ is above window but P2’’ is on window boundary
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
§ We know …
y = mx + b
m = ( y2 – y1) / ( x2 – x1 )
b = y1 – m x1
so…
y = m x + y1 – m x1
y = y1 + m ( x – x1)
also
x = x1 + ( y – y1) / m
§ substitute for y => Ywh or Ywl to calculate x coordinate of intersection
§ Example:
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
(E1 X E2) > 0
(E2 X E3) > 0
(E3 X E4) < 0
(E4 X E5) > 0
(E5 X E6) > 0
(E6 X E7) > 0
§ Cross product:
V1 X V2 = u |V1||V2| sinq
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
E1 = (1, 0, 0)
E2 = (1, 1, 0)
E3 = (1, -1, 0)
E4 = (0, 2, 0)
E5 = (-3, 0, 0)
E6 = (1, -2, 0)
(E1 X E2) = (0, 0, 1)
(E2 X E3) = (0, 0, -2)
(E3 X E4) = (0, 0, 2)
(E4 X E5) = (0, 0, 6)
(E5 X E6) = (0, 0, 6)
(E6 X E7) = (0, 0, 2)
Since E2 X E3 z-value < 0 – must split polygon along line E2
Must determine intersection of line with edge E4
Use slope-intercept form of line:
y = max + ba y = mbx + bb
max + ba = mbx + bb
x = ( bb - ba ) / (ma - mb )
and
x = ( y - ba ) / ma x = ( y – bb ) / mb
( y - ba ) / ma = ( y – bb ) / mb
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Polygon Clipping
§ Polygon boundary processed with a line clipper appears as series of
unconnected line segments
e.g.
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
Need algorithm that will generate one or more closed areas that can be scan
converted
1. 1st outside, 2nd inside
intersection points and inside points added to output vertex list
2. 1st inside, 2nd inside
2nd vertex added to output vertex list
3. 1st inside, 2nd outside
intersection added to output vertex list
4. 1st outside, 2nd outside
nothing added to output vertex list
VEC/IT
CS 8092 COMPUTER GRAPHICS III YR VI SEM 2017 REGULATION
e.g.
VEC/IT