Computer Graphics
Computer Graphics
Question Solve-2020
Question 1
Statement:
The Midpoint Circle Algorithm is an efficient algorithm used to draw a circle on a raster display. It
determines the pixels closest to the ideal circle by choosing between two candidate pixels at each step
based on a decision parameter (midpoint criterion), thereby avoiding the use of square root or
trigonometric functions.
Explanation:
The algorithm typically starts from the point (0,r) and plots pixels in the first octant (from x=0 to x=y).
Due to symmetry, the other seven octants can be easily derived.
The core idea is to evaluate a decision parameter (or midpoint parameter) to choose between two
candidate pixels at each step:
the two candidate pixels for the next step are (x k+1,y k) and (x k +1,y k −1).
For points on the circle, F(x,y)=0. For points inside, F(x,y)<0. For points outside, F(x,y)>0.
If p k<0, the midpoint is inside the circle or on the boundary. We choose the pixel (x k+1,y k ).
If pk
≥0, the midpoint is outside the circle. We choose the pixel (x k+1,y k−1).
The next decision parameter p k+1=p k+2x k −2y k+5.
The initial decision parameter p0is calculated for the starting point (0,r), which is
p 0 =F(1,r−0.5)
=1 2+(r−0.5) 2 −r 2
=1+r 2−r+0.25−r 2
=1.25−r.
If we use integer arithmetic, p0 can be initialized to 1−r (by multiplying by 4 and ignoring constants).
The algorithm iterates, incrementing x by 1 at each step and decrementing y only when necessary, until
x≥y.
(b) To illustrate the Bresenham line drawing algorithm digitize the line with end points (20, 10) and (30,
18). The line has a slope of 0.8.
Given:
Calculations:
Δx=x 1 −x 0 =30−20=10
K Current Point (x k ,y k )p k
p +2Δy−2Δx=6+16−20=21
(21, 11)2(22, 12)
p 1+2Δy−2Δx=2+16−20=−2
p 2+2Δy=−2+16=14
p 3+2Δy−2Δx=14+16−20=10
p 4+2Δy−2Δx=10+16−20=6
p 5+2Δy−2Δx=6+16−20=2
p 6+2Δy−2Δx=2+16−20=−2
p 7+2Δy=−2+16=14
p 8 +2Δy−2Δx=14+16−20=10
p 9+2Δy−2Δx=10+16−20=6
Digitized Points:
(20, 10), (21, 11), (22, 12), (23, 12), (24, 13), (25, 14), (26, 15), (27, 16), (28, 16), (29, 17), (30, 18).
Question 2
(a) Given points P1(1,2,0), P2(3,6,20), and P3(2,4,6) and a view point C(0,0,-10), determine which points
obscure the others when viewed from C.
To determine which points obscure others, we can project the points onto the view plane and compare
their depths. A simpler approach for collinear points (which these might implicitly be, or we can check
for general case) is to compare the z values of the points along the line of sight from the viewpoint. The
point closer to the viewpoint along that line will obscure the one further away.
Let's use a parametric approach for lines of sight from C to each point.
if Q lies between C and P on the line segment CP. This means Q is collinear with C and P, and the
distance CQ<CP.
First, let's check for collinearity of any two points with the viewpoint.
Now, let's check if any of these vectors are scalar multiples of each other.
Is CP 2 a scalar multiple of CP 1 ?
(3,6,30)=k(1,2,10)
3=k⋅1⟹k=3
6=k⋅2⟹k=3
30=k⋅10⟹k=3
Yes,
CP 2=3
CP 1 .
This means C, P1, and P2 are collinear. Since k=3>1, P1 is closer to C than P2. Therefore, P1 obscures P2.
Is CP 3 a scalar multiple of CP 1 ?
(2,4,16)=k(1,2,10)
2=k⋅1⟹k=2
4=k⋅2⟹k=2
16=k⋅10⟹k=1.6
The k values are not consistent. So, C, P1, and P3 are not collinear.
Is CP 3 a scalar multiple of CP 2?
(2,4,16)=k(3,6,30)
2=k⋅3⟹k=2/3
4=k⋅6⟹k=4/6=2/3
16=k⋅30⟹k=16/30=8/15
The k values are not consistent. So, C, P2, and P3 are not collinear.
Conclusion:
Based on the collinearity check, P1 obscures P2. P3 is not collinear with C and either P1 or P2, so it does
not obscure them, nor is it obscured by them in this configuration.
(b) What is the maximum number of objects that can be presented by using Z-buffer algorithm?
The Z-buffer algorithm (also known as the depth buffer algorithm) uses a buffer (the Z-buffer) to store
the depth (Z-value) of the closest object at each pixel on the screen.
The maximum number of objects that can be presented by using the Z-buffer algorithm is theoretically
unlimited.
The Z-buffer algorithm determines visibility on a per-pixel basis. For each pixel on the screen, it stores
the depth of the object currently visible at that pixel. When a new object is rendered, its depth value at
each pixel is compared with the existing depth value in the Z-buffer. If the new object is closer (has a
smaller Z-value, assuming Z increases away from the camera), its color and depth are written to the
frame buffer and Z-buffer, respectively. Otherwise, it is discarded.
Therefore, the Z-buffer algorithm can handle any number of objects, limited only by the available
memory for storing the objects themselves and the computational power to process them. The number
of objects does not affect the maximum number of objects it can present, only the performance
(rendering time). The resolution of the Z-buffer (number of bits per pixel for depth) affects the precision
of depth comparisons, not the number of objects.
(c) The matrix ( 1 011 ) defines a transformation called a simultaneous shearing or shearing for short.
The special case when b=0 is called shearing in the x-direction. When a=0, we have shearing in the y-
direction. Illustrate the effect of shearing transformations on the square A(0,0), B(1,0), C(1,1), and D(0,1)
when a=2 and b=3.
The problem statement gives ( 1011 ) and then refers to a and b in a context that seems to imply a
general shearing matrix ( 1ba1 ).
Let's assume the question meant a general 2D shear matrix where a is the x-shear factor and b is the y-
shear factor, applied as:
A = (0,0)
B = (1,0)
C = (1,1)
D = (0,1)
For A(0,0):
A ′ =( 1321 )( 00 )=( 00 )
For B(1,0):
For D(0,1):
Original Square:
A = (0,0)
B = (1,0)
C = (1,1)
D = (0,1)
A' = (0,0)
B' = (1,3)
C' = (3,4)
D' = (2,1)
Correct.
Correct.
Correct.
Visual Representation:
Original Square:
Transformed Parallelogram:
The base of the square that was on the x-axis (A to B) now extends upwards to (1,3), showing the y-
shear. The side D to C which was a vertical line at x=0 has been transformed to D'(2,1) to C'(3,4),
demonstrating both x and y shearing. This is a "simultaneous shear" as described in the question,
affecting both x and y coordinates based on the other coordinate.
*Question 3:*
A point (x, y) is considered inside the clip window if it satisfies the following inequalities:
where the clip window is defined by the coordinates (x_min, y_min) and (x_max, y_max).
(b) Definitions:
- Clipping: Clipping is a process that identifies and removes those portions of a graphical object (such
as a point, line, or polygon) that lie outside a specified region called the clip window. It is used to display
only the part of the object that is within the visible area of the screen or window.
- Clip Window: The clip window is a rectangular region in the world coordinates that defines the
boundary of the visible area. Any part of the graphical object that lies inside the clip window is
displayed, and the part outside is discarded.
This algorithm is used for line clipping. It uses a region code for each endpoint of the line segment to
determine whether the line is completely inside, completely outside, or partially inside the clip window.
Steps:
1. Assign a 4-bit region code to each endpoint of the line. The bits represent:
2. If both endpoints have a region code of 0000, then the line is completely inside the clip window and
is accepted.
3. If the bitwise AND of the region codes of the two endpoints is not 0000, then the line is completely
outside the clip window and is rejected.
4. If the line is neither accepted nor rejected by the above tests, then the line is partially inside. We
then find an intersection point of the line with one of the clip window boundaries. We divide the line at
the intersection point, discard the part that is outside, and repeat the process for the remaining
segment.
For a line from (x1, y1) to (x2, y2), the intersection with a clip boundary (left, right, bottom, top) can
be calculated using the slope of the line.
y = y1 + m * (x_min - x1)
*Question 4:*
where R is the distance from the center of the tube to the center of the torus, and r is the radius of the
tube.
- Convex hull: The convex hull of a set of points is the smallest convex polygon that contains all the
points. For spline curves, the convex hull of the control points is the smallest convex set that contains all
the control points. It is used to bound the curve and for intersection testing.
- Control graph: The control graph (also called control polygon) is the polyline formed by connecting
the control points in sequence. It provides a visual representation of the control points and their
ordering, and it is used to guide the shape of the spline curve.
Cardinal splines are a type of cubic interpolation spline that passes through each control point (except
the first and last if not closed). They are defined by a series of cubic polynomial segments, each defined
by four control points. The curve is C1 continuous (i.e., continuous in both position and tangent) at the
control points.
Properties:
where t is a tension parameter (usually between 0 and 1) that controls the tightness of the curve.
When t=0, the curve is called a Catmull-Rom spline.
The cubic segment between P_k and P_{k+1} is defined by the four control points: P_{k-1}, P_k,
P_{k+1}, P_{k+2}.
The parametric equation for the segment from P_k to P_{k+1} is:
P(u) = s_0 + s_1 * u + s_2 * u^2 + s_3 * u^3, for u in [0,1]
s_0 = P_k
s_1 = T_k
The tension parameter t affects the curve: as t increases, the curve becomes tighter (pulled towards
the control polygon), and as t decreases, the curve becomes looser.
Cardinal splines are local: changing one control point affects at most four segments of the curve.
Solution to Question 3
Xmin ≤ x ≤ xmax and ymin ≤ y ≤ ymax x min ≤ x≤ x max and y min ≤ y ≤ y max where the clip window is
defined by boundaries xmin x min , xmax x max, ymin y min , and ymax y max .
(b) Definitions
Clipping: The process of removing parts of a graphical primitive (e.g., point, line, polygon) that lie
outside a specified region (clip window). It ensures only visible portions are rendered.
Clip Window: A rectangular region in world coordinates that defines the visible area. Objects are clipped
against this window.
This algorithm clips lines against a rectangular window using region codes for endpoints:
Trivial Acceptance: If both endpoints have code 0000, the line is fully inside → accept.
Trivial Rejection: If the bitwise AND of both codes is non-zero, the line is fully outside → reject.
Replace the endpoint with the intersection point and update the region code.
Key Insight: Efficiently handles lines by leveraging simple bitwise operations and iterative clipping
against boundaries.
Solution to Question 4
A torus is a doughnut-shaped 3D object generated by revolving a circle about a coplanar axis (not
intersecting the circle). It has two radii:
Major Radius (RR): Distance from the center of the torus to the center of the tube.
Convex Hull: The smallest convex polygon enclosing all control points of a spline. It bounds the curve
and aids in intersection tests.
Control Graph: A polyline connecting control points in sequence. It visually approximates the spline’s
shape and guides its curvature.
Cardinal splines interpolate control points using piecewise cubic polynomials, ensuring C1 C1continuity.
Key features:
P(u)=a+bu2+cu+d,u∈[,1]P(u)=au3+bu2+cu+d,u∈[0,1]
Coefficients a,b,c,D a,b,c,d are derived from Pk−1,Pk,Pk+1Pk+2P k−1 ,P k ,P k+1,P k+2 and TTk+1T k,T k+ .
Properties:
Answers are concise yet comprehensive, covering all subparts as specified in the exam question.
1. a) To illustrate the Bresenham line drawing algorithm, digitize the line with endpoints (20, 10) and
(30, 18). The line has a slope of 0.8 with Δx=10 and Δy=8.
Bresenham's algorithm is an efficient algorithm for drawing a line segment between two given points. It
uses integer arithmetic to determine the next pixel to be plotted, avoiding floating-point calculations.
The core idea is to choose the pixel that is closest to the true line.
Initialize:
The digitized points are: (20,10), (21,11), (22,12), (23,12), (24,13), (25,14), (26,15), (27,16), (28,16),
(29,17), (30,18).
The Midpoint Circle Algorithm is an efficient method for drawing a circle by determining the pixels that
are closest to the true circle boundary. It uses integer arithmetic, similar to Bresenham's line algorithm,
making it computationally fast.
Key Idea:
The algorithm starts with an initial point (0,r) and uses symmetry to plot points in all eight octants of the
circle. It calculates a decision parameter to determine which of the two possible next pixels (one moving
diagonally, one moving horizontally/vertically) is closer to the true circle.
Steps (for a circle centered at origin (0,0) with radius r):
Initialize:
While x<y:
Increment x: x=x+1
End: When x≥y, the algorithm stops. The last remaining symmetric points are plotted.
Advantages:
Projections in computer graphics are methods used to display a 3D object on a 2D plane (the screen).
They can be broadly classified into two main categories:
I. Parallel Projections:
In parallel projections, the projection lines are parallel to each other and perpendicular to the projection
plane. This means that parallel lines in 3D remain parallel in the 2D projection. This type of projection is
often used for engineering and architectural drawings where preserving relative proportions and exact
measurements is important.
Properties:
Preserves parallel lines: Parallel lines in 3D objects appear as parallel lines in the projection.
Preserves relative proportions: The relative sizes of objects are maintained. If two objects are the same
size in 3D, they will appear the same size in the projection, regardless of their distance from the viewer.
No perspective effect: Objects do not appear smaller as they move further away. This can make it
difficult to perceive depth.
Lack of realism: The resulting image does not look like what a human eye would see.
Orthographic Projections: The direction of projection is normal (perpendicular) to the projection plane.
Multiview Orthographic: Shows multiple 2D views (e.g., front, top, side) of an object. Excellent for
precise measurements and detailed design.
Axonometric: The projection plane is not parallel to any of the coordinate axes.
Isometric: All three axes are equally foreshortened, and the angles between the projected axes are 120
degrees. Gives a somewhat realistic, but still dimensionally accurate, view.
Oblique Projections: The direction of projection is not perpendicular to the projection plane. This allows
for a more "3D" feel while still preserving one face of the object in true size.
Cavalier: The projection lines make a 45-degree angle with the projection plane. Full depth is shown.
Cabinet: The projection lines make a 63.4-degree angle with the projection plane. Depth is
foreshortened by half, leading to a more realistic appearance than Cavalier.
Properties:
Creates a sense of depth and realism: Objects appear smaller as they move further away from the
viewer.
Does not preserve parallel lines: Parallel lines (except those parallel to the projection plane) appear to
converge at vanishing points.
Does not preserve relative proportions: Distant objects appear smaller than closer objects of the same
size.
Vanishing points: Lines that are parallel in 3D converge to a single point on the projection plane called a
vanishing point.
Used for realistic scenes: Common in art, photography, and realistic computer graphics.
One-Point Perspective: One primary vanishing point, usually used for viewing objects head-on. Parallel
lines perpendicular to the projection plane converge to this single point.
Two-Point Perspective: Two vanishing points, typically used when viewing objects from an angle. Parallel
lines in two different directions converge to two separate vanishing points.
Three-Point Perspective: Three vanishing points, used when viewing objects from an extreme angle
(e.g., looking up at a tall building or down from a great height). All three sets of parallel lines converge to
different vanishing points.
2. b) What are the basic transformation techniques used in Window-to-Viewport transformation? Derive
the viewing transformation matrix.
Window-to-Viewport transformation is the process of mapping a region of the world coordinate system
(the "window") to a region on the screen (the "viewport"). This essentially involves scaling and
translation operations. The basic transformation techniques involved are:
Scaling: To adjust the size of the window to fit the size of the viewport. This involves calculating scaling
factors for both the X and Y dimensions.
Translation: To move the scaled window to the correct position within the viewport. This involves
translating the origin of the scaled window to the origin of the viewport.
Let's define:
Step 1: Translate the window so that its lower-left corner coincides with the origin.
w minand −Y wmin .
After this translation, a point (X w,Y w) becomes (X w−X w min,Y w−Y w min).
The scaling factors are determined by the ratio of viewport dimensions to window dimensions.
S x = X w max−X w mX v max−X v minS y= Yw max−Y w minY v max−Y v minThe scaling matrix S is:S= S
x000s0000After scaling, a point (X w−X w min,Y w−Y w min ) becomes ((X w-xw min)Sx,(Y w−Y w min)S y
).
Step 3: Translate the scaled window so that its lower-left corner coincides with the viewport's lower-left
corner.
Now, multiply T 2⋅
S x000S y0−S xXw min−S yY w min1M wv=S x000S y0X v min−S xX w min Y v min −S yY w min1
for a given window coordinate (X w,Y w) are:X v=X w Sx+X v min−S X w minY v =Y w S y+Y v min −S y w
min
It is not essential that clipping take place before projection. In fact, clipping can occur at different stages
of the graphics pipeline, and the optimal stage often depends on the type of projection and the specific
implementation.
However, a more accurate statement to explain (and perhaps what the question intended to ask,
common in older contexts) is: Why is clipping typically performed in 3D (or object/world coordinates)
before the final 2D projection onto the screen?
Here's why clipping (specifically, against the viewing frustum or viewing volume) is often performed
before the final 2D projection:
Computational Efficiency:
Clipping in 3D is generally more efficient: Clipping a 3D object against a 3D viewing volume (a frustum
for perspective projection, or a rectangular prism for parallel projection) involves comparing 3D
coordinates.
Complexity of 2D Clipping after Projection: If you project all 3D objects to 2D first, you might end up
projecting a large number of primitives (lines, polygons) that are entirely outside the visible screen area.
Then, performing 2D clipping on these already projected primitives would be redundant and
computationally wasteful. Clipping in 3D first ensures that only the visible parts (or potentially visible
parts) of objects are passed down the pipeline for projection and further processing.
Preserving Depth Information: In 3D clipping, depth information is still readily available. This is crucial
for correctly clipping against the near and far clipping planes of the viewing volume, which define the
visible depth range. If you project to 2D first, depth information might be lost or become more complex
to work with for clipping.
Perspective effects change line segments: In perspective projection, a straight line segment in 3D might
become a different kind of curve or behave unexpectedly if clipped after projection in 2D. Clipping in 3D
handles these situations correctly because it works with the true 3D geometry before it's distorted by
perspective.
Clipping planes in perspective space: For perspective projection, clipping is often done against the
normalized device coordinates (NDC) space or clip space, which is a canonical 3D volume (typically from
-1 to 1 in x, y, z). This allows for a uniform clipping approach regardless of the original frustum shape.
Early discard of invisible geometry: Clipping away geometry that is outside the view frustum reduces the
amount of data that needs to be processed by subsequent stages like rasterization and Z-buffering (for
hidden surface removal). If objects outside the view were projected, they would still consume
processing power during rasterization and Z-buffer calculations, even if they ultimately wouldn't be
visible.
Question 3:
However, since we are in a text-based environment, we will describe the process and the matrices
involved.
In 2D graphics, rotation is typically done about the origin. However, if we want to rotate about an
arbitrary pivot point (x_r, y_r), we can break it down into three steps:
1. Translate the object so that the pivot point moves to the origin. This is done by translating by (-x_r, -
y_r).
3. Translate the object back by (x_r, y_r) to return the pivot point to its original position.
The transformation matrix for this composite operation is:T(x_r, y_r) * R(θ) * T(-x_r, -y_r)
Where:
[0, 0, 1 ] [ 0, 0, 1] [0, 0, 1 ]
[ 0, 0, 1] [0, 0, 1] [ 0, 0, 1 ]
[1, 0, x_r] [cosθ, -sinθ, -x_r*cosθ + y_r*sinθ] [cosθ, -sinθ, -x_r*cosθ + y_r*sinθ + x_r]
[0, 1, y_r] * [sinθ, cosθ, -x_r*sinθ - y_r*cosθ] = [sinθ, cosθ, -x_r*sinθ - y_r*cosθ + y_r]
[0, 0, 1 ] [ 0, 0, 1 ] [ 0, 0, 1 ]
[ 0, 0, 1 ]
Reflection about the line y=x can be achieved by swapping the x and y coordinates. The transformation
matrix is:
[0, 1, 0]
[1, 0, 0]
[0, 0, 1]
c) Only with neat diagrams show the sequence of transformations for rotating an object about an axis
that is parallel to the x-axis.
Since the axis is parallel to the x-axis, we can assume it is at a distance d from the x-axis (say, at y = d).
We can break down the rotation about this axis into:
1. Translate the object so that the axis of rotation (y=d) coincides with the x-axis. This is done by
translating by (0, -d).
[1, 0, 0, 0]
[0, 0, 0, 1] (for 3D, but since we are rotating about an axis parallel to x, and in 2D we consider the
plane, but note: the problem says "rotating an object about an axis that is parallel to the x-axis". This
implies we are in 3D? However, the course is Computer Graphics and the exam is for CSE-3221, which
might include 3D. But the question is under Part A and the previous parts are 2D. Let me clarify: the axis
is parallel to the x-axis, but the object is in 3D? However, the question says "only with neat diagrams", so
we describe the steps.
But note: in 2D, rotating about an arbitrary point is covered in (a). Now, if we are rotating about an axis
(which is a line) parallel to the x-axis, then we are in 3D. However, the question does not specify. But
looking at the context, the course is Computer Graphics and this is a common 3D transformation.
But the question is in Part A and the other parts are 2D. Let me see the exact wording: "rotating an
object about an axis that is parallel to the x-axis". Since it says "axis", it is likely 3D. However, the
diagram might be 2D projections? Alternatively, we can consider the rotation in 3D and then project to
2D? But the question only asks for the sequence of transformations.
Let the axis be parallel to the x-axis and passing through (0, d, 0) [assuming in the xy plane, but actually
it can be anywhere, but without loss of generality, we can assume it is at y=d, z=0]. Then:
1. Translate the object by (0, -d, 0) so that the axis becomes the x-axis.
[0,0,0,1]
But note: the last column for y-translation is d(1 - cosθ) and for z is -d*sinθ.
However, since we are asked for diagrams, we cannot draw, but we can describe:
Question 4:
a) What are the steps involved in Cohen-Sutherland algorithm for line clipping.
The Cohen-Sutherland algorithm clips a line against a rectangular window. It uses region codes to
identify the position of the endpoints relative to the window.
Steps:
1. Assign a 4-bit region code to each endpoint of the line. The bits represent:
2. Check for trivial acceptance: if both endpoints have region code 0000, then the line is completely
inside -> accept.
3. Check for trivial rejection: if the bitwise AND of the region codes of the two endpoints is not 0000,
then the line is completely outside -> reject.
4. If not trivial acceptance or rejection, then we need to clip the line. Pick an endpoint that is outside
(any one that is not 0000). Find the intersection point of the line with the window boundary (using the
edge that corresponds to the outermost bit set in the region code). Replace the outside endpoint with
the intersection point and update the region code for that endpoint.
5. Repeat steps 2 to 4 until the line is either accepted or rejected.
b) What is "canonical viewing space"? Describe in detail the Sutherland-Hodgeman algorithm for
clipping a polygon to the view volume in this space.
Canonical viewing space (also called normalized device coordinates) is a coordinate system where the
view volume is a normalized cube (for parallel projection) or a normalized frustum (for perspective
projection) that is used to simplify clipping. In particular, for 2D, the canonical view volume is often a
square from (-1,-1) to (1,1). In 3D, for parallel projection, the canonical view volume is the unit cube
from (-1,-1,-1) to (1,1,1).
This algorithm clips a polygon against a convex clipping window (or view volume). It works by clipping
the polygon against each boundary of the clipping window one after the other.
1. Clip the polygon against the left boundary of the window. This means we process all polygon vertices
against the left edge (x = x_min). For each edge of the polygon (defined by two consecutive vertices, say
from vertex i to vertex j), we check:
- If both vertices are inside the left boundary, then output the second vertex.
- If the first vertex is inside and the second is outside, then output the intersection point of the edge
with the left boundary.
- If the first vertex is outside and the second is inside, then output the intersection point and then the
second vertex.
We do this for every edge and build a new list of vertices for the polygon clipped against the left
boundary.
2. Repeat step 1 for the right boundary (x = x_max), then the bottom boundary (y = y_min), and then the
top boundary (y = y_max). After each boundary, we use the output polygon as the input for the next
boundary.
The algorithm works for convex clipping regions and produces a single closed polygon.
- Sutherland-Hodgeman clips a polygon by processing it against each boundary of the clipping window in
sequence. It clips the entire polygon against one boundary at a time, and the output of one stage is the
input to the next.
- Cohen-Sutherland can handle any convex window, but Sutherland-Hodgeman is designed for convex
clipping regions (and works for rectangular windows).
- Cohen-Sutherland might have to clip a line against multiple boundaries, and it uses the region codes to
determine which boundary to clip against first. Sutherland-Hodgeman clips against each boundary in a
fixed order.
Solution to Question 3
Rotating an object about an arbitrary pivot point (xr,yr)(x r ,y r ) involves three steps:
Composite Transformation
Matrix:M=T(xr,yr)⋅R(θ)⋅T(−xr,−yr)=[cosθ−sinθxr(1−cosθ)+yrsinθsinθcosθyr1-
cosθ)−xsinθ001]M=T(x r,y r)⋅R(θ)⋅T(−x r,−y r)= cosθsinθ0−sinθcosθ0x r(1−cosθ)+y rsinθy r(1−cosθ)−x r
sinθ1
Solution to Question 4
Trivial Acceptance: Both endpoints have code 0000 → accept the line.
A normalized coordinate system where the view volume is a unit cube ([−1,1]3[−1,1] 3).
Repeat for right (x=xmaxx=xmax ), bottom (y=yminy=y min), and top (y=ymaxy=y max ) edges.
ComplexityO(1)
Question solve-2019
State: Bresenham's line algorithm is an efficient algorithm for drawing lines on a raster display,
which uses only integer arithmetic. It determines the next pixel to plot by evaluating the sign of a
decision parameter, thereby avoiding floating-point calculations.
Explanation:
The algorithm works by incrementally determining the next pixel that best approximates the
ideal line. It starts at one endpoint and progresses towards the other, choosing between two
possible pixels at each step (either horizontally adjacent or diagonally adjacent). The choice is
made based on a decision parameter (often denoted as 'p' or 'd') that represents the distance
between the true line and the midpoint between the two candidate pixels.
Initialization:
o Calculate Δx=∣x2−x1∣ and Δy=∣y2−y1∣.
o Initialize the decision parameter P0=2Δy−Δx.
o Set the starting point (x,y) to (x1,y1).
Iteration (for slope 0≤m≤1):
o For each step, increment x by 1.
o If Pk<0, the next point is (xk+1,yk), and Pk+1=Pk+2Δy.
o If Pk≥0, the next point is (xk+1,yk+1), and Pk+1=Pk+2Δy−2Δx.
Generalization: The algorithm can be adapted for other slopes by swapping Δx and Δy if
∣Δy∣>∣Δx∣, and by handling negative slopes and starting points appropriately (e.g.,
drawing from right to left if x1>x2).
The key advantage of Bresenham's algorithm is its speed and simplicity, as it only uses integer
additions, subtractions, and bit shifts, which are very fast operations for a processor.
1.b) Given a circle radius r=10. Demonstrate the midpoint circle drawing
algorithm determining position along the circle octant in the first quadrant from
x=0 to y=x.
The algorithm uses the implicit equation of a circle: x2+y2−r2=0. We evaluate the midpoint
between two candidate pixels to decide which one is closer to the true circle.
Initialization:
Next
(xk,yk)
Pk (Decision Condition Point
k (Current Pk+1 (New Decision Parameter)
Parameter) Pk<0? (xk+1
Point)
,yk+1)
0 (0, 10) -9 Yes (1, 10) P0+2x0+3=−9+2(0)+3=−6
1 (1, 10) -6 Yes (2, 10) P1+2x1+3=−6+2(1)+3=−1
2 (2, 10) -1 Yes (3, 10) P2+2x2+3=−1+2(2)+3=6
P3+2x3+5−2y3
3 (3, 10) 6 No (4, 9)
=6+2(3)+5−2(10)=6+6+5−20=−3
4 (4, 9) -3 Yes (5, 9) P4+2x4+3=−3+2(4)+3=8
P5+2x5+5−2y5
5 (5, 9) 8 No (6, 8)
=8+2(5)+5−2(9)=8+10+5−18=5
P6+2x6+5−2y6
6 (6, 8) 5 No (7, 7)
=5+2(6)+5−2(8)=5+12+5−16=6
x=y condition no longer holds, but for
7 (7, 7) 6 No (8, 6) demonstration, P7+2x7+5−2y7
=6+2(7)+5−2(7)=6+14+5−14=11
Export to Sheets
(0, 10), (1, 10), (2, 10), (3, 9), (4, 9), (5, 8), (6, 8), (7, 7).
2.a) Define Translation, Rotation and Scaling for two dimensional geometric
transformations.
x′y′1=100010txty1xy1
Rotation: Rotation is a rigid-body transformation that rotates an object about a fixed point called
the pivot point or center of rotation. Every point in the object rotates by the same angle.
x′y′1=cosθsinθ0−sinθcosθ0001xy1
Rotation about an arbitrary pivot point (xp,yp): This involves three steps:
1. Translate the object so the pivot point moves to the origin.
2. Rotate the object about the origin.
3. Translate the object back so the pivot point returns to its original position.
Scaling: Scaling is a non-rigid-body transformation that changes the size of an object. It can
either enlarge or reduce the object. Scaling can be uniform (same scaling factor in all directions)
or non-uniform (different scaling factors in different directions).
x′y′1=sx000sy0001xy1
Scaling about an arbitrary fixed point (xf,yf): This involves three steps:
1. Translate the object so the fixed point moves to the origin.
2. Scale the object about the origin.
3. Translate the object back so the fixed point returns to its original position.
2.b) With neat diagrams, explain the general pivot-point rotation or two
dimensional geometric transformations.
1. Translate the object so that the pivot point coincides with the origin. If the pivot
point is Pp(xp,yp), we apply a translation T(−xp,−yp).
T1=100010−xp−yp1
Diagram: Imagine an object with its pivot point. In this step, you shift the entire object
so that this pivot point now sits exactly on the (0,0) coordinate.
2. Rotate the object about the origin. We apply the standard rotation matrix R(θ) for the
desired angle θ.
R=cosθsinθ0−sinθcosθ0001
Diagram: With the pivot now at the origin, you perform the rotation as if the object was
centered there.
3. Translate the object back so that the pivot point returns to its original position. We
apply an inverse translation T(xp,yp).
T2=100010xpyp1
Diagram: Finally, you shift the rotated object back by the same amount you initially
shifted it, so the pivot point is back where it started. The object is now rotated around its
original pivot point.
M=100010xpyp1cosθsinθ0−sinθcosθ0001100010−xp−yp1
This sequence ensures that the object rotates around the specified pivot point rather than the
coordinate origin.
Shearing is a transformation that distorts the shape of an object by shifting points in one direction
proportional to their distance from an axis or plane. It essentially "skews" the object. In 3D,
shearing can occur along any axis relative to any other axis or plane.
How it modifies 3D object shapes:
Imagine a cube. If you apply a shear transformation along the X-axis relative to the YZ-plane,
the faces perpendicular to the X-axis will shift horizontally. The bottom face might stay in place,
while the top face slides to the side. This transforms the cube into a parallelogram (or a
parallelepiped in 3D).
x′y′z′1=1000shx100shx0100001xyz1
x′y′z′1=1shy0001000shy100001xyz1
x′y′z′1=10shz001shz000100001xyz1
Effects on 3D objects:
Distortion of Angles: Angles between faces and edges change, unless the shear is
perfectly aligned with one of the principal axes.
Slanting: Objects appear to be "pushed over" or slanted. A rectangular prism can become
a parallelepiped.
Volume Preservation: A pure shear transformation (without scaling) preserves the
volume of the object. This is because the determinant of a shear matrix is 1.
Creating new shapes: Shearing can be combined with other transformations (translation,
rotation, scaling) to create complex and stylized 3D shapes that would be difficult to
model otherwise. For example, creating italicized text in 3D or simulating the effect of
wind on a tall structure.
In essence, shearing provides a powerful tool for non-uniform deformations, allowing for artistic
effects and realistic simulations of object distortion under various forces or stylistic
requirements.
Analogy: If the entire scene is a large photograph, the window is the particular section of
the photograph you want to zoom in on, and the viewport is the frame on your screen
where that zoomed-in section will be shown.
The window-to-viewport transformation is the process of mapping a point from the world-
coordinate window to the device-coordinate viewport. This transformation scales and translates
the contents of the window to fit into the specified viewport, preserving the relative positions of
objects.
Let:
1. Normalization (Scaling): First, the coordinates within the window are normalized to a
range of [0,1] (or sometimes [−1,1] for normalized device coordinates). This is achieved
by scaling the window such that its width and height become 1.
Normalized x-coordinate:
Xw,max−Xw,minxw−Xw,min
Normalized y-coordinate:
Yw,max−Yw,minyw−Yw,min
2. Scaling to Viewport Size: Next, these normalized coordinates are scaled to the
dimensions of the viewport. Scaling factor for x:
S_x=fracX_v,max−X_v,minX_w,max−X_w,min Scaling factor for y:
S_y=fracY_v,max−Y_v,minY_w,max−Y_w,min
Note: To maintain aspect ratio, usually S_x and S_y are chosen as the minimum of the
two, and then the viewport is centered within the device. However, for a general
transformation, they can be different, which can lead to distortion.
xv=Xv,min+(xw−Xw,min)Xw,max−Xw,minXv,max−Xv,min
yv=Yv,min+(yw−Yw,min)Yw,max−Yw,minYv,max−Yv,min
These equations can be expressed more compactly using scaling and translation factors:
xv=Xv,min+(xw−Xw,min)⋅Sx
yv=Yv,min+(yw−Yw,min)⋅Sy
This process effectively maps any point (x_w,y_w) within the defined window to a
corresponding point (x_v,y_v) within the viewport on the display device.
The Weiler-Atherton polygon clipping algorithm is a polygon clipping algorithm used to clip
one polygon (the subject polygon) against another polygon (the clip polygon). It is particularly
effective for convex and concave polygons and can handle self-intersecting polygons.
Explanation:
The algorithm works by traversing the vertices of both the subject polygon and the clip polygon
in a specific order, identifying intersections, and determining which segments of the subject
polygon are inside the clip polygon. The key idea is to follow the outlines of the polygons.
1. Identify Entry and Exit Points: For each edge of the subject polygon, determine if it
intersects any edge of the clip polygon. Mark these intersection points. An intersection
point is classified as an "entry" point if the subject polygon crosses from outside to inside
the clip polygon, and an "exit" point if it crosses from inside to outside.
2. Order Intersection Points: Along each edge of the subject polygon, order the
intersection points.
3. Traverse and Output:
o Start at an "entry" intersection point on the subject polygon.
o Trace the subject polygon's edges until an "exit" intersection point is reached. All
vertices and segments encountered between an "entry" and "exit" point are part of
the clipped polygon. Add these to the output.
o When an "exit" point is reached on the subject polygon, switch to tracing the clip
polygon's edges from that "exit" point in the direction that keeps you inside the
subject polygon.
o Continue tracing the clip polygon's edges until an "entry" point on the clip
polygon is reached that corresponds to a segment of the subject polygon that is
now inside the clip polygon.
o Switch back to tracing the subject polygon's edges from this new "entry" point.
o Repeat this process until you return to the starting "entry" point.
4. Handling No Intersections:
o If the subject polygon is entirely inside the clip polygon, the entire subject
polygon is the result.
o If the subject polygon is entirely outside the clip polygon, the result is an empty
set (no polygon).
Illustration (Conceptual):
1. Initial State:
2. +-----------------+ (Clip Polygon - RED)
3. | |
4. | /-----------/ | (Subject Polygon - BLUE)
5. | | | |
6. | \---------/ |
7. | |
8. +-----------------+
9. Identify Intersections and Entry/Exit: The algorithm finds points where the blue
polygon crosses the red polygon's boundary. Each crossing is marked as an "entry" (blue
enters red) or "exit" (blue leaves red).
10. +-----------------+
11. | E2 |
12. | /--I1----I2--/ |
13. | | | |
14. | \--I3----I4--/ |
15. | E1 |
16. +-----------------+
(I1, I2, I3, I4 are intersection points. E1, E2 are examples of entry/exit points from
subject to clip or vice versa depending on traversal.)
17. Traverse:
o Start at an entry point (e.g., I_1).
o Follow the subject polygon's edge to the next intersection (I_2). Output the
segment I_1rightarrowI_2.
o At I_2 (an exit point), switch to following the clip polygon's edge in the direction
that keeps you inside until you reach the next relevant entry point (e.g., I_4).
Output the segment I_2rightarrowI_4 along the clip polygon.
o At I_4 (an entry point), switch back to following the subject polygon's edge to the
next intersection (I_3). Output segment I_4rightarrowI_3.
o At I_3 (an exit point), switch to following the clip polygon's edge until you return
to the start (I_1). Output segment I_3rightarrowI_1 along the clip polygon.
Resulting Clipped Polygon (Green): The output would be a new polygon (or set of polygons)
formed by the segments traced, which represents the part of the subject polygon that lies inside
the clip polygon.
+-----------------+
| |
| /-----------/ |
| | | |
| \---------/ |
| |
+-----------------+
(Green Clipped Polygon)
The Weiler-Atherton algorithm is known for its robustness, especially with concave and complex
polygons, as it handles various intersection scenarios by carefully tracking the traversal direction
within and along the boundaries of both polygons.
Example: Bézier curves and B-splines are common examples of approximation splines.
The curve will be influenced by points A, B, C, and D, but it might not pass through any
of them except possibly the first and last (in some cases like Bézier curves).
4.b) What are the parametric continuity conditions to ensure smooth transition
from one section of a precise parametric curve to the next?
To ensure a smooth transition between curve segments (e.g., in a composite Bézier curve or B-
spline), we use parametric continuity conditions at the join points. These conditions define the
level of smoothness. The common types are C0, C1, and C2 continuity.
Let P_1(t) be the first curve segment and P_2(t) be the second curve segment, joined at
parameter value t=1 for P_1 and t=0 for P_2.
Hermite Interpolation is a method for constructing a smooth curve (or polynomial) that passes
through a given set of data points and also matches specified tangent vectors (derivatives) at
those points. Unlike standard interpolation which only requires the curve to pass through points,
Hermite interpolation provides control over the curve's slope at each point.
State: Hermite interpolation constructs a polynomial that not only interpolates specific points but
also matches predefined derivative values (tangent vectors) at those points. For a cubic Hermite
curve, this means specifying two endpoints and two tangent vectors (one at each endpoint).
Explanation:
A common application is the cubic Hermite spline, which connects two points, P_0 and P_1,
with associated tangent vectors, R_0 and R_1, respectively. The curve segment is typically
defined parametrically for t from 0 to 1.
The general form of a cubic Hermite curve segment P(t) is given by:
P(t)=H0(t)P0+H1(t)P1+H2(t)R0+H3(t)R1
Where H_i(t) are the Hermite Basis Functions (or blending functions):
H_0(t)=2t3−3t2+1
H_1(t)=−2t3+3t2
H_2(t)=t3−2t2+t
H_3(t)=t3−t2
1. Interpolates Endpoints:
o At t=0: P(0)=1cdotP_0+0cdotP_1+0cdotR_0+0cdotR_1=P_0. The curve starts at
P_0.
o At t=1: P(1)=0cdotP_0+1cdotP_1+0cdotR_0+0cdotR_1=P_1. The curve ends at
P_1.
2. Matches Tangent Vectors: The first derivative of P(t) with respect to t gives the tangent
vector:
P′(t)=H0′(t)P0+H1′(t)P1+H2′(t)R0+H3′(t)R1
Advantages:
Local Control: Changing an endpoint or tangent vector only affects the specific curve
segment, not the entire curve (if it's a composite Hermite spline).
Precise Shape Control: The ability to specify tangent vectors at each point allows for
very precise control over the curve's shape and its "tightness" or "looseness."
Smoothness: When multiple Hermite segments are joined, C1 continuity can be easily
achieved by ensuring that the tangent vector at the end of one segment is the same as the
tangent vector at the beginning of the next segment (scaled appropriately). C2 continuity
can also be achieved by matching second derivatives.
Applications:
Question solve-2018
1.a) Illustrate the Bresenham's Line Drawing Algorithm, digitize the line with endpoints
(4,0) to (20, 10) and (30, 18) with a shape of 0.8 with Δx = 10 and Δy = 8
Given:
o (x_1,y_1)=(4,0)
o (x_2,y_2)=(20,10)
Calculate Δx and Δy:
o Deltax=x_2−x_1=20−4=16
o Deltay=y_2−y_1=10−0=10
Calculate initial decision parameter (p_0):
o p_0=2Deltay−Deltax=2(10)−16=20−16=4
Bresenham's Algorithm Steps:
k p_k (x_{k+1}, y_{k+1})
0 4 (5,1)
1 -8 (6,1)
2 12 (7,2)
3 0 (8,3)
4 -12 (9,3)
5 8 (10,4)
6 -4 (11,4)
7 16 (12,5)
8 4 (13,6)
9 -8 (14,6)
10 12 (15,7)
11 0 (16,8)
12 -12 (17,8)
13 8 (18,9)
14 -4 (19,9)
15 16 (20,10)
The digitized points for the first segment are: (4,0), (5,1), (6,1), (7,2), (8,3), (9,3), (10,4), (11,4),
(12,5), (13,6), (14,6), (15,7), (16,8), (17,8), (18,9), (19,9), (20,10)
This part of the question is a bit ambiguous. "Shape of 0.8" and "with Δx = 10 and Δy = 8" don't
directly fit into a standard line drawing algorithm context without specifying a second point. It
seems like it might be an attempt to describe a vector from (30,18).
Assuming it means a line starting at (30,18) with a change of Δx = 10 and Δy = 8, the end point
would be (30+10, 18+8) = (40,26). Let's proceed with this assumption.
Given:
o (x_1,y_1)=(30,18)
o (x_2,y_2)=(40,26)
Calculate Δx and Δy:
o Deltax=x_2−x_1=40−30=10
o Deltay=y_2−y_1=26−18=8
Calculate initial decision parameter (p_0):
o p_0=2Deltay−Deltax=2(8)−10=16−10=6
Bresenham's Algorithm Steps:
06 (31,19)
12 (32,20)
2 -2 (33,20)
3 14 (34,21)
4 10 (35,22)
56 (36,23)
62 (37,24)
7 -2 (38,24)
8 14 (39,25)
9 10 (40,26)
Export to Sheets
The digitized points for the second segment (assuming an endpoint of (40,26)) are: (30,18),
(31,19), (32,20), (33,20), (34,21), (35,22), (36,23), (37,24), (38,24), (39,25), (40,26)
1.b) Explain midpoint circle drawing algorithm. Is there any advantage of using this
algorithm over other circle drawing algorithm?
Steps:
1. Initialize:
o Set the center of the circle (x_c,y_c) and the radius R.
o Set the starting point (x,y)=(0,R).
o Calculate the initial decision parameter p_0=1−R (or p_0=5/4−R for integer
arithmetic, which is more common in implementations).
2. Iterate: While $x \< y$:
o If $p\_k \< 0$:
The next point is (x+1,y).
Update the decision parameter: p_k+1=p_k+2x+3.
o Else (p_kge0):
The next point is (x+1,y−1).
Update the decision parameter: p_k+1=p_k+2x−2y+5.
o Increment x by 1. If p_kge0, decrement y by 1.
o Plot the points in all 8 octants using the current (x,y) and (x_c,y_c):
(x_c+x,y_c+y)
(x_c−x,y_c+y)
(x_c+x,y_c−y)
(x_c−x,y_c−y)
(x_c+y,y_c+x)
(x_c−y,y_c+x)
(x_c+y,y_c−x)
(x_c−y,y_c−x)
When concatenating successive scaling operations in 2-D composite transformation, the resulting
output is Multiplicative.
Explanation:
If you apply two successive scaling operations, say S_1(s_x1,s_y1) followed by S_2(s_x2,s_y2),
the combined transformation matrix is found by multiplying their individual matrices:
S_combined=S_2cdotS_1
As you can see, the final scaling factors in the combined matrix are the products of the
individual scaling factors (s_x2s_x1 and s_y2s_y1). This demonstrates that successive scaling
operations are multiplicative.
To perform a rotation around an arbitrary pivot point, we use a sequence of three basic
transformations:
1. Translate the object so that the pivot point (x_p,y_p) moves to the origin (0,0).
2. Rotate the object around the origin by the desired angle θ.
3. Translate the object back so that the pivot point moves back to its original position
(x_p,y_p).
Diagrams:
Initial State:
A
/ \
/ \
B-----C
.
. P(xp, yp)
A'
/ \
/ \
B'----C'
.
P'(0,0)
Transformation: T(−x_p,−y_p)
The object is rotated around the new origin (which was P).
A''
/ \
/ \
C''---B''
.
P''(0,0)
Transformation: R(θ)
A'''
/ \
/ \
C'''--B'''
.
. P'''(xp, yp)
Transformation: T(x_p,y_p)
The composite transformation matrix is the product of these three matrices, applied in reverse
order of operation (from right to left):
M_pivot_rotation=T(x_p,y_p)cdotR(theta)cdotT(−x_p,−y_p)
2.c) Draw and label the reflection of an object relative to an axis perpendicular to the XY
plane and passing through point P.
This question describes a reflection about an axis that is perpendicular to the XY plane and
passes through a point P. This essentially means reflecting an object in 3D space across a line
that extends infinitely up and down from point P. However, in a 2D context, this usually
simplifies to a point reflection through point P.
Let's assume the question implies a 2D reflection about the point P (a 180-degree rotation around
P), as reflections about a line perpendicular to the XY plane in a 2D drawing effectively flip an
object through a point.
If a point (x,y) is reflected through a point (x_p,y_p), the new point (x′,y′) is given by:
x′=x_p−(x−x_p)=2x_p−x y′=y_p−(y−y_p)=2y_p−y
Diagram:
Initial State:
A
/ \
/ \
B-----C
.
P
The object is "flipped" or rotated 180 degrees around point P. Each point on the object will have
its corresponding reflected point such that P is the midpoint of the segment connecting the
original point and its reflection.
C'-----B'
\ /
\ /
A'
.
P
Labeling:
Original Object: Triangle ABC
Point of Reflection: P
Reflected Object: Triangle A'B'C'
Each vertex of the original object is reflected through P to form the corresponding vertex of the
reflected object.
2.d) Only with neat diagram, illustrate the 3D scaling operation with respect to a selected
2.50 fixed position (x_f, y_f, z_f).
Similar to 2D scaling with respect to a fixed point, 3D scaling with respect to a fixed position
(x_f,y_f,z_f) involves three steps:
1. Translate the object so that the fixed position (x_f,y_f,z_f) moves to the origin
(0,0,0).
2. Scale the object with respect to the origin by scaling factors s_x,s_y,s_z.
3. Translate the object back so that the fixed position moves back to its original
coordinates (x_f,y_f,z_f).
Diagram:
Initial State:
Z
^
|
| C2-----D2 (top face)
| /| /|
| B2--A2 |
| | | |
| | C1-|--D1 (bottom face)
| | / | /
| A1----B1
+----------------> Y
/
/
X
. P(xf, yf, zf)
The cube is scaled with respect to the origin (which was P). The size changes, but the corner at
the origin remains fixed.
Z
^
|
| C2''----D2''
| /| /|
| B2''--A2'' |
| | | |
| | C1''-|--D1''
| | / | /
| A1''---B1''
+----------------> Y
/
/
X
P''(0,0,0)
Z
^
|
| C2'''----D2'''
| /| /|
| B2'''--A2''' |
| | | |
| | C1'''-|--D1'''
| | / | /
| A1'''---B1'''
+----------------> Y
/
/
X
. P'''(xf, yf, zf)
The composite transformation matrix is the product of these three matrices, applied in reverse
order of operation (from right to left):
M_fixed_point_scaling=T(x_f,y_f,z_f)cdotS(s_x,s_y,s_z)cdotT(−x_f,−y_f,−z_f)
What is Transformation?
The distinction between geometric transformations and coordinate transformations can be subtle,
but it's important to understand the different contexts in which they are used.
Mathematical Basis Matrix applied to object points Matrix applied to coordinate system axes
Export to Sheets
The mention of "3.00 coordinate transformation" in the question is a bit unusual. It might be a
typo and simply refer to 2D or 3D coordinate transformations in general, or perhaps a specific
numerical context that isn't immediately obvious without further information. Assuming it refers
to coordinate system changes in general, the above explanation holds.
3.b) Perform a 60° rotation of a triangle A(1,1), B(11, 2) and C(5,5) about the origin and
4.75 about P(-1, 0).
Part 2: Rotation of a triangle A(1,1), B(11, 2) and C(5,5) about P(-1, 0) (4.75 is unclear,
assuming it's a typo, and the angle is still 60 degrees, or if it is a different angle it is not
provided in question). Assuming 4.75 is an unrelated number or typo. If it's a specific
angle, please provide it. If not, I will continue with the assumption of 60 degrees as in
previous step.
Since the angle for the second rotation isn't explicitly given with a unit (like degrees or radians)
and "4.75" appears to be a floating-point number without context, I will assume it's a typo or
extraneous information, and the intent is to rotate by 60 degrees again, but this time around the
pivot point P(-1, 0).
1. Translate the object so that the pivot point moves to the origin: T(−xp,−yp)
2. Rotate the object about the origin: R(θ)
3. Translate the object back so that the pivot point moves back to its original
position: T(xp,yp)
y′=(x−(−1))⋅0.866+(y−0)⋅0.5+0 y′=(x+1)⋅0.866+y⋅0.5
4.a) Suppose you have a system with an 8-inch by 10-inch video screen that can display 100
2.75 pixels per inch. If a color lookup table with 64 positions is used with this system. What
is the smallest possible size (in bytes) for the frame buffer?
Let's break this down step by step to calculate the frame buffer size.
Correction: It's highly unlikely that a screen would have non-integer pixels or such a low
resolution (27.5x22 pixels). The "100" before "2.75 pixels per inch" seems to be part of
the PPI value. Let's re-interpret "100 2.75 pixels per inch" as "100.275 pixels per inch" or
perhaps "100 pixels per inch, and the 2.75 is irrelevant." Given the phrasing, it's more
probable that "100 pixels per inch" is the correct interpretation and "2.75" is either a typo
or refers to something else entirely (e.g., color depth or refresh rate).
Therefore, the smallest possible size for the frame buffer is 600,000 bytes.
(Self-correction on PPI interpretation): If "2.75 pixels per inch" was the sole PPI value, then
10×2.75=27.5 and 8×2.75=22. This would lead to 27.5×22=605 pixels.
605 pixels×6 bits/pixel=3630 bits. 3630 bits/8=453.75 bytes. This is an extremely low resolution
for a video screen, even an old one, and non-integer pixel counts are physically impossible. The
"100" almost certainly modifies "pixels per inch." Hence, 100 PPI is a more reasonable
interpretation.
4.b) Derive the following equations for transformation from an initial Cartesian system to
an angle θ relative to the first system. Transformation equations can be obtained by
projecting point P onto each of the four axes and analyzing the resulting "right triangles".
x′=xcosθ−ysinθ
y′=xsinθ+ycosθ
These are the standard equations for a 2D rotation of a point (x,y) around the origin by an angle θ
to obtain the new point (x′,y′).
Consider a point P(x,y) in the original Cartesian coordinate system. We want to find its new
coordinates P′(x′,y′) after rotating the coordinate system (or the point in reverse) by an angle θ
counter-clockwise around the origin.
1. Represent P in Polar Coordinates: Let the distance from the origin to P be r. Let the
angle that the line segment OP makes with the positive x-axis be ϕ. Then, the original
Cartesian coordinates (x,y) can be expressed as: x=rcosϕ y=rsinϕ
2. Rotation: When the point P is rotated counter-clockwise by an angle θ about the origin,
its distance from the origin r remains the same. Only its angle changes. The new angle
will be ϕ+θ.
3. Represent P' in Polar Coordinates: The new point P′(x′,y′) will have polar coordinates
(r,ϕ+θ). Using the same conversion from polar to Cartesian coordinates: x′=rcos(ϕ+θ)
y′=rsin(ϕ+θ)
4. Apply Trigonometric Identities: Now, use the sum-of-angles identities for cosine and
sine:
o cos(A+B)=cosAcosB−sinAsinB
o sin(A+B)=sinAcosB+cosAsinB
These derived equations are the standard 2D rotation equations about the origin, as required.
Question solve-2017
Question 1:
a) Explain the working principle of Liquid Crystal Display (LCD) as a flat panel display
device.
A Liquid Crystal Display (LCD) is a flat-panel display that uses the light-modulating properties
of liquid crystals. Liquid crystals do not emit light directly; instead, they use a backlight or
reflector to produce images in color or monochrome.
Backlight: The process begins with a backlight, typically an LED or CCFL (Cold
Cathode Fluorescent Lamp), which provides the illumination. This light is unpolarized.
First Polarizer: The light then passes through a front polarizer. This polarizer only
allows light waves oscillating in a specific plane to pass through, making the light
polarized.
Liquid Crystal Layer: The heart of the LCD is the liquid crystal layer, sandwiched
between two glass substrates. These liquid crystals are unique in that their molecular
orientation can be controlled by an electric field. In their natural, unenergized state, the
liquid crystal molecules are twisted, which causes them to rotate the plane of polarized
light passing through them.
Transparent Electrodes: On the inner surfaces of the glass substrates, transparent
electrodes (usually Indium Tin Oxide - ITO) are patterned. These electrodes apply an
electric field across the liquid crystal layer. Each pixel on an LCD screen corresponds to
a specific area of these electrodes.
Color Filters (for color LCDs): In color LCDs, a layer of red, green, and blue color
filters is placed in front of the second polarizer. Each pixel is divided into sub-pixels,
each with a specific color filter.
Second Polarizer (Analyzer): After passing through the liquid crystal layer (and color
filters), the light encounters a second polarizer, called the analyzer. This polarizer is
oriented at 90 degrees to the first polarizer.
No Voltage (ON state - light passes through): When no voltage is applied to a specific
pixel, the liquid crystal molecules maintain their twisted arrangement. As the polarized
light passes through this twisted structure, its polarization plane is rotated by 90 degrees.
This rotated light is now aligned with the second polarizer, allowing it to pass through
and making the pixel appear bright.
Voltage Applied (OFF state - light blocked): When a voltage is applied to a pixel, the
electric field aligns the liquid crystal molecules parallel to the electric field. This untwists
the liquid crystals, and they no longer rotate the plane of polarized light. The polarized
light, therefore, remains perpendicular to the second polarizer and is blocked, making the
pixel appear dark.
By selectively applying voltage to different pixels, the LCD can control which pixels are bright
and which are dark, thus creating an image. The intensity of the light can also be controlled by
varying the voltage, allowing for different shades of color or gray.
Bresenham's Line Drawing Algorithm is an efficient and accurate algorithm for scan-
converting a line (i.e., drawing a line on a discrete pixel grid) using only integer arithmetic. It
avoids floating-point calculations, making it very fast. The algorithm determines the next pixel to
plot by evaluating an error term that indicates whether the line is closer to the pixel directly
above/below or the pixel diagonally from the current pixel.
Core Idea: When drawing a line from (x_0,y_0) to (x_1,y_1), the algorithm incrementally plots
pixels. At each step, it decides whether to move horizontally (increment x) and vertically
(increment y) or just horizontally (increment x) to stay as close as possible to the true line.
Algorithm Steps (for a line with slope 0lemle1 and $x\_0 \< x\_1$):
The decision parameter P_k (also sometimes denoted as d_k) helps to choose between two
candidate pixels. Consider two potential pixels at (x_k+1,y_k) and (x_k+1,y_k+1). The true line
passes through (x_k+1,y) where y=m(x_k+1−x_0)+y_0.
The decision parameter is derived from the mid-point between the two candidate pixels.
Essentially, it checks the sign of a function that represents the distance of the midpoint from the
ideal line.
If $P\_k \< 0$, it means the midpoint is below the line, so the upper pixel (x_k+1,y_k+1)
is farther away, and the lower pixel (x_k+1,y_k) is closer.
If P_kge0, it means the midpoint is above or on the line, so the lower pixel (x_k+1,y_k)
is farther away, and the upper pixel (x_k+1,y_k+1) is closer.
Advantages:
Integer Arithmetic: Uses only integer additions, subtractions, and bit shifts, making it
very fast.
Efficiency: Does not involve floating-point calculations, divisions, or multiplications,
which are computationally expensive.
Accuracy: Generates accurate and smooth lines.
Limitations:
The version described above is for slopes between 0 and 1. The algorithm needs to be
adapted for other octants (slopes > 1, negative slopes) by swapping Deltax and Deltay,
changing the increment direction, or reflecting coordinates. This often involves
determining the dominant axis (Deltax or Deltay) and iterating along that axis.
Question 2:
Mathematical Representation:
(x′y′)=(sx00sy)(xy)
Where:
x′y′z′=sx000sy000szxyz
Where:
s_x, s_y, and s_z are the scaling factors along the x, y, and z axes, respectively.
Changes Aspect Ratio: Because the scaling is different along each axis, the original
proportions (aspect ratio) of the object are altered. Circles can become ellipses, and
squares can become rectangles.
Distortion: Differential scaling can introduce distortion, making objects appear stretched
or compressed in specific directions.
Applications:
o Resizing images or objects: When it's necessary to fit an image into a specific
display area without maintaining its original proportions.
o Creating special effects: To simulate squash and stretch animations, or to give a
stretched perspective.
o CAD/CAM: Adjusting dimensions of parts independently.
o User Interface Design: Resizing UI elements that need to fill space but don't
require proportional scaling.
Steps Involved:
To scale an object about a fixed point (x_f,y_f), we perform a sequence of three basic
transformations:
1. Translate the object so that the fixed point coincides with the origin.
2. Perform the desired scaling transformation about the origin.
3. Translate the object back so that the fixed point returns to its original position.
Let the original point be P(x,y), the fixed point be F(x_f,y_f), and the scaling factors be s_x and
s_y. The transformed point will be P′(x′,y′).
The overall transformation matrix for 2D general fixed-point scaling can be constructed by
multiplying the individual transformation matrices:
Tscaling_fixed_point=T(xf,yf)⋅S(sx,sy)⋅T(−xf,−yf)
Where:
T(−x_f,−y_f) is the translation matrix to move the fixed point to the origin:
S(s_x,s_y) is the scaling matrix about the origin:
T(x_f,y_f) is the translation matrix to move the object back to its original position:
Tscaling_fixed_point=100010xfyf1sx000sy0001100010−xf−yf1
Tscaling_fixed_point=sx000sy0xfyf1100010−xf−yf1
Tscaling_fixed_point=sx000sy0−sxxf+xf−syyf+yf1
x′=xcdots_x+x_f(1−s_x) y′=ycdots_y+y_f(1−s_y)
Diagrams:
Initial State:
(x, y)
+-------+
| |
| R |
| |
+-------+
F(xf, yf) <-- Fixed Point
Move the entire rectangle such that the fixed point F is now at (0,0).
+-------+
| |
| R' |
| |
+-------+
(0,0) <-- F' (F translated to origin)
+-----------+
| |
| R'' |
| |
+-----------+
(0,0) <-- F' (still at origin, but now scaled)
Translate the scaled rectangle R'' back by (x_f,y_f) so that the fixed point returns to its original
position.
+-----------+
| |
| R''' |
| |
+-----------+
F(xf, yf) <-- Fixed Point (original location)
This sequence ensures that the object scales around the chosen fixed point, maintaining that
point's absolute coordinates while the rest of the object expands or contracts around it.
Unlike algorithms like Sutherland-Hodgman which only output one polygon and struggle with
concave clip windows (producing incorrect results like extraneous lines), Weiler-Atherton
correctly identifies and generates all valid clipped portions.
The main idea behind Weiler-Atherton is to traverse the boundaries of both the subject polygon
and the clip polygon, making decisions at intersection points based on whether an edge is
entering or exiting the clip region. It constructs the clipped polygon(s) by carefully "following"
the appropriate boundary segments.
1. Intersection Calculation:
o Find all intersection points between the edges of the subject polygon and the
edges of the clip polygon.
oFor each intersection point, determine if it's an "entry" point (subject polygon
edge goes from outside to inside the clip polygon) or an "exit" point (subject
polygon edge goes from inside to outside the clip polygon). This is typically
determined by testing the normal of the clip edge and the direction of the subject
edge.
2. Ordering and Linking:
o Sort the intersection points along each edge of both polygons.
o Link the intersection points on the subject polygon edges to their corresponding
intersection points on the clip polygon edges. This creates a data structure where
you can "jump" from one polygon's boundary to the other at intersection points.
3. Traversal and Output:
o Start at an "entry" intersection point on the subject polygon.
o Follow the subject polygon's edges inside the clip window until another
intersection point is encountered.
o At this intersection point (which will be an "exit" point for the subject polygon),
switch to the clip polygon's boundary.
o Follow the clip polygon's edges in the direction that keeps you inside the clip
window until another intersection point (an "entry" point for the subject polygon)
is reached.
o At this "entry" point, switch back to the subject polygon's boundary.
o Continue this process, collecting vertices, until you return to the starting "entry"
point. This completes one clipped polygon.
o Repeat the process for any remaining unvisited "entry" points to find other
clipped polygons (if the subject polygon was split).
Algorithm Variations:
There are variations of the Weiler-Atherton algorithm, some using an "inside-outside" test for
points and others focusing purely on directed edges and intersection types.
Advantages:
Initial State:
Step 1: Find Intersections & Classify (Entry/Exit) Let's say a blue edge enters the red region
at I1 (entry) and exits at I2 (exit).
Step 2: Traversal
Start at I1 (entry).
Follow the blue polygon edge inside the red polygon until I2. Add I1 and segment(I1 to
I2) to output.
At I2, switch to the red clip polygon.
Follow the red polygon edge in a direction that keeps you inside the original red polygon
from I2 until you hit another intersection, say I3. Add segment(I2 to I3) to output.
At I3, switch back to the blue polygon (assuming I3 is an "entry" point for the blue
polygon).
Continue following blue until you reach I4 (exit). Add segment(I3 to I4) to output.
At I4, switch to red. Follow red until you loop back to I1. Add segment(I4 to I1) to
output.
Resulting Clipped Polygon: The collected segments form the new clipped polygon.
+-------+
| .--.|
| / \| (Clipped Polygon - will be bounded by red and blue
segments)
| '-----'|
| |
+--------+
Question 3:
"Blobby" objects, also known as metaballs, soft objects, or implicit surfaces, are a type of 3D
modeling technique used to create organic, amorphous, and fluid-like shapes. Unlike traditional
polygon-based models (which are defined by a mesh of vertices, edges, and faces), blobby
objects are defined implicitly by mathematical functions.
f(x,y,z)=(x−xc)2+(y−yc)2+(z−zc)2R2
(This is a simplified example; actual functions are often more complex to control the
falloff).
2. Summation of Fields: When multiple blobby primitives are placed near each other, their
individual field functions are summed up. This creates a combined, continuous field
across space.
3. Iso-surface (Threshold Value): The actual "surface" of the blobby object is defined by
an iso-surface (or iso-potential surface). This is a surface where the sum of the field
functions equals a specific, predefined threshold value. Points where the combined field
strength is above this threshold are considered "inside" the object, and points where it's
below are "outside."
Key Characteristics:
Organic and Fluid Shapes: As primitives move closer, their fields merge, causing the
surface to "blob" together smoothly. When they move apart, the surface separates. This
creates very natural, flowing, and often biological or liquid-like forms.
Implicit Definition: They are not defined by explicit vertices and faces but by an implicit
equation F(x,y,z)=textthreshold.
Dynamic Topology: The topology (the number of holes, connected components, etc.) of
a blobby object can change dynamically as the primitive elements move relative to each
other. When two blobs get close enough, they merge; when they move apart, they split.
Rendering: Blobby objects are typically rendered using techniques like marching cubes
or other iso-surface extraction algorithms. These algorithms convert the implicit surface
into a polygon mesh that can then be rendered using standard rendering pipelines.
Applications:
Special Effects: Creating realistic liquids, goo, fire, smoke, and other amorphous
phenomena.
Character Modeling: Representing organic body parts, muscles, or soft tissues.
Medical Visualization: Modeling biological structures.
Abstract Art: Generating unique and complex organic forms.
Convex Hull:
In geometry, the convex hull of a set of points in a plane (or higher-dimensional space) is the
smallest convex set that contains all the points. Intuitively, if you imagine the points as nails
sticking out of a board, the convex hull is the shape formed by stretching a rubber band around
all the nails and letting it snap tight.
Convex Set: A set is convex if, for any two points within the set, the line segment
connecting those two points is entirely contained within the set.
Smallest: It's the smallest such convex set, meaning no point can be removed from its
boundary without making it non-convex or excluding one of the original points.
Vertices are from the original set: The vertices of the convex hull are always a subset
of the original input points.
Applications:
o Collision Detection: Simplifying complex object shapes for faster collision
checks (e.g., approximating an object with its convex hull).
o Image Processing: Shape analysis, object recognition.
o Pattern Recognition: Clustering algorithms.
o Computational Geometry: Many geometric algorithms rely on the convex hull.
o Optimization: Finding extreme points.
Diagram (2D):
. .
.
. .
.
.
The convex hull would be the polygon enclosing all these points:
+-----------+
| |
| . . |
| . |
| |
| . . |
| . |
| . |
+-----------+
Control Polygon:
Defines Curve/Surface Shape: The control polygon does not typically lie on the
curve/surface itself (except for the start and end points in some cases, like Bezier curves).
Instead, the shape of the control polygon influences and approximates the shape of the
generated curve or surface.
Intuitive Manipulation: Designers manipulate the control points to intuitively shape the
curve or surface. Moving a control point pulls or pushes the curve/surface in its vicinity.
Convex Hull Property: A fundamental property of many splines (like Bezier curves) is
that the curve is always contained within the convex hull of its control points. This
provides a useful bounding box for calculations and rendering.
Examples:
o Bezier Curves: A Bezier curve is defined by a set of control points. The curve
starts at the first control point and ends at the last. The intermediate control points
"pull" the curve, but the curve generally doesn't pass through them.
o B-Splines/NURBS: These also use control points and a control polygon, but they
offer more local control (moving one control point only affects a limited portion
of the curve/surface).
Let's say we have four control points P0, P1, P2, P3.
P1 o-----o P2
| \
| \
P0 o--------o P3
The lines connecting P0-P1, P1-P2, P2-P3 form the control polygon.
The Bezier curve defined by these points would look something like this, influenced by the
control polygon:
P1 o-----o P2
|\ /
| \ /
P0 o--C--o P3
(Where 'C' represents the smooth curve) Notice the curve (C) starts at P0, ends at P3, and is
pulled towards P1 and P2, but doesn't necessarily pass through them. The control polygon (the
dashed lines) helps to visualize the curve's approximate shape and provides the handles for
manipulation.
Cardinal Splines are a type of interpolating piecewise cubic polynomial in computer graphics.
This means they pass through (interpolate) all their control points, unlike Bezier curves which
only interpolate the start and end points. They are "piecewise" because the overall curve is
composed of multiple cubic polynomial segments, where each segment connects two adjacent
data points.
Key Concepts:
1. Interpolating: A cardinal spline must pass through every control point (also called data
points or knots) that defines it. This is a crucial distinction from approximating splines
like Bezier curves.
2. Piecewise Cubic: The curve is constructed from individual cubic (degree 3) polynomial
segments. Each segment is responsible for connecting two consecutive control points.
3. Local Control: Cardinal splines offer local control. Changing one control point only
affects the two curve segments immediately adjacent to it, providing localized
modification without affecting the entire curve.
4. Continuity: Cardinal splines typically ensure C1 continuity (continuous tangent vectors)
and often C2 continuity (continuous second derivatives, meaning smooth curvature) at
the control points where segments meet. This results in a visually smooth curve without
sharp corners or sudden changes in direction.
5. Tension Parameter (tau or c): A unique feature of cardinal splines is the tension
parameter, often denoted as tau (tau) or c (for cardinal). This parameter controls how
tightly the curve bends between control points.
o High Tension: Makes the curve "tighter" or "straighter," pulling it closer to the
control polygon.
o Low Tension (or zero tension): Makes the curve "looser" or "rounder," allowing
it to deviate further from the control polygon.
o A common value for tau is 0.5. When tau=0, it becomes a Catmull-Rom spline.
A cardinal spline segment is defined by four control points: P_i−1, P_i, P_i+1, and P_i+2. The
segment itself interpolates P_i and P_i+1. The "ghost" points P_i−1 and P_i+2 are used to
calculate the tangent vectors at P_i and P_i+1 to ensure smoothness.
The equation for a point P(u) on the segment between P_i and P_i+1 (where 0leule1) is given by:
P(u)=u3⋅Mcardinal⋅Pvec
P(u)=(F1(u),F2(u),F3(u),F4(u))Pi−1PiPi+1Pi+2
Where F_1(u),F_2(u),F_3(u),F_4(u) are the blending functions, and M_cardinal is the cardinal
matrix:
(Note: Some texts use c as a tension factor, others as a "bias" or "continuity" factor. Here, let's
assume c is related to tension. Often tension T=1−c, or c directly controls tension).
At each interpolating point P_i, the tangent vector for the curve segment leaving P_i and the
curve segment entering P_i are made equal. The tangent at P_i is typically approximated using
the vector between the preceding point P_i−1 and the succeeding point P_i+1, scaled by the
tension parameter.
The tension parameter directly controls the magnitude of these tangent vectors, influencing how
sharply the curve bends.
Applications:
Animation Path Generation: Creating smooth paths for objects or cameras to follow.
Font Design: Defining smooth character outlines.
Interactive Design: Allowing users to intuitively draw and modify smooth curves by
placing points.
Data Interpolation: Smoothly connecting discrete data points.
Diagram:
Let's say we have control points P0, P1, P2, P3, P4.
A cardinal spline would pass through all these points, with segments connecting P0-P1, P1-P2,
P2-P3, P3-P4. The points P(-1) and P5 (imaginary or clamping) would be used for the tangents at
P0 and P4.
P0 P1 P2 P3 P4
o-------o-------o-------o-------o (Control points / Interpolated
points)
/ \ / \ / \ / \ / \
/ \ / \ / \ / \ / \
C-----C-----C-----C-----C-----C-----C
(Smooth Cardinal Spline Curve)
Notice how the curve passes directly through each 'o' (control point). The tension parameter
would adjust how much the curve "hugs" the straight lines between the points or rounds out
more.
Question 4:
The Cohen-Sutherland line clipping algorithm is a widely used and efficient algorithm for
clipping line segments against a rectangular clip window. It uses a region-code approach to
quickly determine if a line segment is entirely inside, entirely outside, or partially inside the clip
window. This allows for early rejection of lines that are clearly outside the view.
Key Concepts:
1. Region Codes (Outcodes): The core idea is to assign a 4-bit region code (or outcode) to
each endpoint of a line segment. Each bit in the code corresponds to a specific boundary
of the clip window (top, bottom, right, left).
The bits are typically ordered as TBRL (Top, Bottom, Right, Left).
The region code 0000 means the point is inside the clip window.
1. Choose an endpoint that is outside the window (i.e., its outcode is not 0000). Let this be
P_k with outcode C_k.
2. Identify which boundary P_k crosses based on its outcode bits (e.g., if the Top bit is set,
it crosses the top boundary).
3. Calculate the intersection point of the line segment with that boundary.
o For Top boundary (y=Y_max): x_int=x_1+(x_2−x_1)fracY_max−y_1y_2−y_1
y_int=Y_max
o For Bottom boundary (y=Y_min):
x_int=x_1+(x_2−x_1)fracY_min−y_1y_2−y_1 y_int=Y_min
o For Right boundary (x=X_max):
y_int=y_1+(y_2−y_1)fracX_max−x_1x_2−x_1 x_int=X_max
o For Left boundary (x=X_min): y_int=y_1+(y_2−y_1)fracX_min−x_1x_2−x_1
x_int=X_min
4. Replace the outside endpoint P_k with the new intersection point (x_int,y_int). This new
point is now on the boundary.
5. Recalculate the outcode for the new endpoint.
6. Repeat the process (back to step 1 of "Clipping Decisions") with the modified line
segment until it falls into either the trivial accept or trivial reject case.
Example Walkthrough:
Line A-B: Both endpoints inside (0000 AND 0000 = 0000) -> Trivial Accept.
Line C-D: Outcodes for C and D would have the 'right' bit set. (C_C AND C_D) = 0010 -
> Trivial Reject.
Line E-F:
o E is outside (e.g., Top, Left bits set)
o F is inside (0000)
o Not trivial accept/reject. Clip!
o Let's say E crosses Top first. Calculate intersection E'. Replace E with E'.
o Now check E'-F. E' might still be outside another boundary (e.g., Left).
o Clip E' with Left. Get E''. Replace E' with E''.
o Now E''-F. E'' and F are both inside. Trivial Accept. Draw E''F.
Advantages:
Disadvantages:
Iterative for Complex Lines: For lines that cross multiple boundaries, the algorithm
iterates, calculating multiple intersection points for a single line segment. This can be less
efficient than algorithms like Liang-Barsky for such cases.
Floating-point Arithmetic: Intersection calculations still involve floating-point
numbers.
b) Use the Cohen-Sutherland algorithm to clip line P1 (70,20) and P2 (100,10) against a
window lower left hand corner (50, 10) and upper right hand corner (80, 40).
Given:
Clip Window:
o X_min=50
o Y_min=10
o X_max=80
o Y_max=40
Line Segment:
o P_1=(70,20)
o P_2=(100,10)
x_1=70, y_1=20
y_1Y_max (20 > 40)? No (Top bit: 0)
$y\_1 \< Y\_{min}$ (20 < 10)? No (Bottom bit: 0)
x_1X_max (70 > 80)? No (Right bit: 0)
$x\_1 \< X\_{min}$ (70 < 50)? No (Left bit: 0) Outcode (C1) for P1 = 0000 (Inside)
x_2=100, y_2=10
y_2Y_max (10 > 40)? No (Top bit: 0)
$y\_2 \< Y\_{min}$ (10 < 10)? No (Bottom bit: 0)
x_2X_max (100 > 80)? Yes (Right bit: 1)
$x\_2 \< X\_{min}$ (100 < 50)? No (Left bit: 0) Outcode (C2) for P2 = 0010 (Right)
Trivial Accept? (C1 == 0000 AND C2 == 0000) (0000 AND 0010) is not 0000. So, no
trivial accept.
Trivial Reject? (C1 AND C2) != 0000 (0000 AND 0010) = 0000. So, no trivial reject.
Step 3: Clipping Required
Since it's neither trivial accept nor trivial reject, we need to clip. P2 is outside (C2 = 0010). We
clip P2 against the Right boundary.
The intersection point is (80,16.67) (approximately). Let's call this new point P_2′=(80,16.67).
x=80, y=16.67
yY_max (16.67 > 40)? No (Top bit: 0)
$y \< Y\_{min}$ (16.67 < 10)? No (Bottom bit: 0)
xX_max (80 > 80)? No (Right bit: 0)
$x \< X\_{min}$ (80 < 50)? No (Left bit: 0) Outcode (C2') for P2' = 0000 (Inside)
Trivial Accept? (C1 == 0000 AND C2' == 0000) (0000 AND 0000) = 0000. Yes!
Trivial Accept.
Result: The clipped line segment is from (70, 20) to (80, 16.67).
Question solve-2015
Problem 1
Explanation:
The core idea is to choose the next pixel (either x+1,y or x+1,y+1 for a positive slope less than 1)
by checking which one is closer to the true line. This is done by evaluating a decision parameter,
often denoted as pk.
Let's consider the case where the slope m is between 0 and 1 (i.e., 0≤m≤1) and the line is drawn
from left to right.
1. Initialize:
o Plot the starting point (x0,y0).
o Calculate Δx=∣x1−x0∣ and Δy=∣y1−y0∣.
o Calculate the initial decision parameter p0=2Δy−Δx.
2. Iteration: For each xk from x0 to x1−1:
o If pk<0: The next pixel is (xk+1,yk). Update pk+1=pk+2Δy.
o If pk≥0: The next pixel is (xk+1,yk+1). Update pk+1=pk+2Δy−2Δx.
This process continues until x reaches x1. The algorithm can be adapted for other octants and
slopes by considering the signs of Δx and Δy and swapping roles of x and y if the slope is greater
than 1.
b) Given a circle radius: r=10. Demonstrate the midpoint circle algorithm by determining
position along the circle octant in the first quadrant from x=0 to x=y.
The midpoint circle algorithm is used to draw a circle by determining the pixels that are closest
to the circle's arc. It uses a decision parameter to choose between two possible pixels at each
step.
Given r=10. We will determine points in the first octant (from x=0 to x=y). The initial point is
(0,10).
1. Initialize:
o Start point (x0,y0)=(0,10).
o Initial decision parameter p0=1−r=1−10=−9.
2. Iteration:
o k = 0:
Current point: (0,10)
p0=−9<0.
Next point: (x0+1,y0)=(1,10).
p1=p0+2x0+3=−9+2(0)+3=−6.
Symmetric points: (1,10), (10,1).
o k = 1:
Current point: (1,10)
p1=−6<0.
Next point: (x1+1,y1)=(2,10).
p2=p1+2x1+3=−6+2(1)+3=−1.
Symmetric points: (2,10), (10,2).
o k = 2:
Current point: (2,10)
p2=−1<0.
Next point: (x2+1,y2)=(3,10).
p3=p2+2x2+3=−1+2(2)+3=6.
Symmetric points: (3,10), (10,3).
o k = 3:
Current point: (3,10)
p3=6≥0.
Next point: (x3+1,y3−1)=(4,9).
p4=p3+2x3−2y3+5=6+2(3)−2(10)+5=6+6−20+5=−3.
Symmetric points: (4,9), (9,4).
o k = 4:
Current point: (4,9)
p4=−3<0.
Next point: (x4+1,y4)=(5,9).
p5=p4+2x4+3=−3+2(4)+3=8.
Symmetric points: (5,9), (9,5).
o k = 5:
Current point: (5,9)
p5=8≥0.
Next point: (x5+1,y5−1)=(6,8).
p6=p5+2x5−2y5+5=8+2(5)−2(9)+5=8+10−18+5=5.
Symmetric points: (6,8), (8,6).
o k = 6:
Current point: (6,8)
p6=5≥0.
Next point: (x6+1,y6−1)=(7,7).
p7=p6+2x6−2y6+5=5+2(6)−2(8)+5=5+12−16+5=6.
Symmetric points: (7,7). At this point x=y, so we stop.
Positions along the circle octant in the first quadrant from x=0 to x=y for r=10:
(0, 10), (1, 10), (2, 10), (3, 10), (4, 9), (5, 9), (6, 8), (7, 7)
Problem 2
x′y′1=100010txty1xy1
The translation vector specifies the amount of shift along each axis.
For example, in 2D, if you scale an object by a factor sx along the x-axis and sy along the
y-axis, and sx =sy, then it's differential scaling. If a point (x,y) is subjected to
differential scaling, its new coordinates (x′,y′) are x′=x⋅sx and y′=y⋅sy. In matrix form,
using homogeneous coordinates, a 2D differential scaling is represented as:
x′y′1=sx000sy0001xy1
Differential scaling is useful for creating effects like stretching or squashing objects, or
for fitting objects into specific non-proportionate spaces.
General fixed-point scaling refers to scaling an object or a set of points with respect to an
arbitrary fixed point, rather than the origin (0,0). When scaling with respect to the origin, the
object expands or shrinks away from or towards the origin. However, in many graphics
applications, it's necessary to scale an object while keeping a specific point on the object (or in
space) stationary. This specific point is called the "fixed point" or "pivot point."
1. Translate the fixed point to the origin: Shift the entire object so that the chosen fixed
point (xf,yf) coincides with the origin (0,0). This is achieved by translating the object by
(−xf,−yf).
T(−xf,−yf)=100010−xf−yf1
2. Perform the desired scaling: Apply the scaling transformation (uniform or differential)
with respect to the origin. If the scaling factors are sx and sy, the scaling matrix is:
S(sx,sy)=sx000sy0001
3. Translate the fixed point back to its original position: Shift the scaled object back by
translating it by (xf,yf).
T(xf,yf)=100010xfyf1
Combining these three transformations, the composite transformation matrix for scaling with
respect to a fixed point (xf,yf) is:
M=T(xf,yf)⋅S(sx,sy)⋅T(−xf,−yf)
This sequence ensures that the fixed point remains at its original location while the rest of the
object scales around it.
Shear (also known as skew) is a 2D geometric transformation that distorts the shape of an object
by shifting all points within it in a given direction, proportional to their distance from a fixed line
(the shear axis). Unlike translation, rotation, or scaling, shear changes the angles between lines
and the area of the object (if the shear is not parallel to one of the axes and involves scaling the
other axis). Parallel lines remain parallel, but the shape generally deforms.
1. X-direction Shear (Shearing parallel to the x-axis): In this type of shear, the x-
coordinates of points are shifted based on their y-coordinates. The y-coordinates remain
unchanged. The transformation equations are: x′=x+shx⋅y y′=y where shx is the shear
factor relative to the x-axis. A larger shx results in a greater horizontal shift for points
further from the x-axis. The matrix representation is:
x′y′1=100shx10001xy1
Visually, a square might transform into a parallelogram where the top edge shifts
horizontally relative to the bottom edge.
2. Y-direction Shear (Shearing parallel to the y-axis): In this type of shear, the y-
coordinates of points are shifted based on their x-coordinates. The x-coordinates remain
unchanged. The transformation equations are: x′=x y′=y+shy⋅x where shy is the shear
factor relative to the y-axis. The matrix representation is:
x′y′1=1shy0010001xy1
Visually, a square might transform into a parallelogram where the right edge shifts
vertically relative to the left edge.
Problem 3
The Weiler-Atherton polygon clipping algorithm is a technique used to clip a polygon against a
clipping window (another polygon, often a rectangle). It's particularly useful for concave
polygons and guarantees correct output. Unlike some other algorithms that only handle convex
polygons or might produce incorrect results for concave ones, Weiler-Atherton can produce
multiple output polygons if the original polygon is clipped into disconnected pieces.
Explanation:
The core idea of the Weiler-Atherton algorithm is to traverse the edges of both the subject
polygon (the polygon to be clipped) and the clip polygon. It determines the intersections between
their edges and identifies which parts of the subject polygon lie inside the clipping window.
The algorithm works by maintaining a list of "active" vertices for both the subject and clip
polygons. It then follows these rules:
1. Initialization: Start at an "entry" vertex (a vertex of the subject polygon that is entering
the clip window, or an intersection point where the subject polygon enters the clip
window).
2. Traversal Rules:
o If the current edge of the subject polygon is inside the clip window: Follow
the subject polygon's edge until an intersection point is encountered or the end of
the edge is reached. Add the vertices along this segment to the output polygon.
o If the current edge of the subject polygon is outside the clip window: Move to
the clip polygon's edge at the current intersection point and follow the clip
polygon's boundary until an intersection point is encountered where the subject
polygon re-enters the clip window. Add the vertices of the clip boundary to the
output polygon.
o At an intersection point: Decide whether to continue along the subject polygon's
edge or switch to the clip polygon's edge based on whether the subject polygon is
entering or exiting the clip window. An "entering" intersection point means the
subject polygon crosses the clip boundary from outside to inside, and an "exiting"
intersection point means it crosses from inside to outside.
3. Output: The algorithm continues tracing until it returns to the starting vertex or all
relevant parts of the polygon have been identified. The collected vertices form the clipped
polygon(s).
Key Features:
Handles Concave Polygons: Its primary advantage is its ability to correctly clip concave
polygons, potentially resulting in multiple output polygons.
Intersection Detection: Requires robust intersection detection between polygon edges.
Directional Traversal: The concept of "entering" and "exiting" points and the
directional traversal are crucial for its correctness.
These terms are primarily used in the context of splines and Bezier curves, which are
fundamental tools for creating smooth curves and surfaces in computer graphics.
Control Graph (or Characteristic Polygon for B-splines): The control graph refers to
the sequence of line segments connecting the control points of a spline curve (like a B-
spline or NURBS curve). It's a piecewise linear approximation of the curve. While the
curve itself is smooth, the control graph provides a visual representation of the influence
and shape of the control points. For B-splines, the control graph is specifically called the
"characteristic polygon."
o Purpose: The control graph helps visualize how adjusting the position of a
control point will affect the overall shape of the curve. It does not necessarily pass
through all control points (e.g., for B-splines), but it guides the curve's path.
Control Polygon (for Bezier Curves): The control polygon is a specific term used for
Bezier curves. It is the polygon formed by connecting the control points of a Bezier
curve in sequence. Unlike general splines, a Bezier curve always starts at the first control
point and ends at the last control point. The intermediate control points pull the curve
towards them.
o Purpose: The control polygon defines the shape of the Bezier curve. The curve is
tangent to the first and last segments of the control polygon. The convex hull
property of Bezier curves states that the curve is always contained within the
convex hull of its control polygon. This provides a clear boundary for the curve
and helps in its manipulation and analysis.
In essence, both terms describe the geometric arrangement of control points that implicitly define
a smooth curve. The "control polygon" is a more specific term usually associated with Bezier
curves, while "control graph" can be used more generally, especially for B-splines.
The Cardinal Spline interpolation method is a technique used to create a smooth curve that
passes through a given set of data points (interpolation). It's a type of cubic spline, meaning that
the curve segments between any two consecutive data points are defined by cubic polynomials.
The key characteristic of a Cardinal Spline is that it allows the user to control the "tension" of the
curve, which affects how tightly or loosely the curve bends around the data points.
How it works:
For a set of n+1 data points P0,P1,…,Pn, a Cardinal Spline defines a curve that interpolates all
these points. Each segment of the curve between two adjacent data points Pi and Pi+1 is
determined by Pi, Pi+1, and their two neighboring points Pi−1 and Pi+2 (if they exist).
The mathematical formulation for a point P(t) on the curve segment between Pi and Pi+1 (where
0≤t≤1) often involves a matrix multiplication of the geometric vector [Pi−1 Pi Pi+1 Pi+2]T and a
blending function matrix.
The blending functions (or basis functions) for a Cardinal Spline incorporate a tension parameter,
often denoted by c (where 0≤c≤1, or sometimes τ where τ=1−c).
Advantages:
Disadvantages:
Requires two extra points (one before the first data point and one after the last) for
segments at the ends, or special handling for boundary conditions.
Cardinal Splines are widely used in computer graphics for animation paths, drawing tools, and
representing smooth object contours because of their intuitive tension control and interpolating
nature.
Problem 4
a) Explain with neat diagrams, the Fractal Dimension, to describe the detail variation in
fractal objects.
Fractal Dimension is a concept that extends the traditional notion of dimension (like 1D for a
line, 2D for a plane, 3D for a volume) to quantify the complexity and self-similarity of fractals.
Unlike Euclidean objects, whose dimensions are integers, fractals often have non-integer (or
"fractal") dimensions. It describes how much "space" a fractal object appears to fill, or how its
detail changes as you zoom in.
These are integer dimensions. If you zoom in on a segment of a line, it still looks like a line. If
you zoom in on a portion of a plane, it still looks like a plane. The detail doesn't change
significantly in terms of how it fills space.
Fractal Objects and Self-Similarity: Fractal objects exhibit self-similarity, meaning that parts
of the object resemble the whole at different scales. As you magnify a fractal, you often see
intricate details that are similar to the larger structure. This inherent detail at all scales is what the
fractal dimension attempts to capture.
Imagine covering an object with boxes (or circles, or cubes) of a certain size ϵ. As you make the
boxes smaller (decrease ϵ), you need more boxes to cover the object. For a traditional object, the
number of boxes N(ϵ) increases predictably:
In general, for a Euclidean dimension DE, N(ϵ)∝(1/ϵ)DE. Taking the logarithm of both sides:
logN(ϵ)∝DElog(1/ϵ). So, DE=limϵ→0log(1/ϵ)logN(ϵ).
For a fractal, this relationship holds, but the exponent DF (the fractal dimension) is often not an
integer.
DF=ϵ→0limlog(1/ϵ)logN(ϵ)
Apply the same process (divide each segment into three, remove middle, add triangle) to
each of the four new segments created in Iteration 1.
The curve becomes even more jagged and intricate.
Imagine zooming in on any small segment of the Koch curve at a high iteration.
You will see that the zoomed-in portion looks exactly like the larger curve (self-
similarity). This is the key.
As you move from Iteration 0 to Iteration 1, 2, and so on, the curve gets longer and more
complex, filling more space than a simple 1D line.
If you take a segment of the Koch curve and scale it down by a factor of 3, you get 4
copies of the original segment.
Using the fractal dimension formula for self-similar fractals (DF
=log(scaling factor)log(number of self-similar pieces)):
o Number of pieces = 4
o Scaling factor = 3
o DF=log3log4≈1.2618
Interpretation: The Koch curve is "more than a line" (dimension > 1) because it's so
convoluted and fills space more effectively than a straight line. However, it's "less than a
plane" (dimension < 2) because it doesn't completely fill a 2D area. Its fractal dimension
of approximately 1.2618 reflects this intermediate level of "space-filling" and its infinite
detail at successive magnifications.
Sierpinski Gasket: Starts with a triangle, repeatedly removes central triangles. Its fractal
dimension is log3/log2≈1.585. It's a planar object but has holes, making it less than 2D.
Mandelbrot Set: A complex fractal. Its boundary has a fractal dimension of 2, meaning
it is so complex and fills space so completely that its boundary is as dense as a 2D plane.
In summary, fractal dimension quantifies how the "amount of detail" or "roughness" of an object
changes with scale. A higher fractal dimension indicates a more complex, space-filling, and
detailed object.
b) Illustrate and explain the "Self-squaring" fractals as a method for generating fractal
objects.
"Self-squaring" fractals refer to a class of fractals generated by iteratively applying a
mathematical function, specifically involving squaring operations (often in the complex plane),
to points. The most famous example of a self-squaring fractal is the Mandelbrot Set. The
iterative process often reveals patterns that are self-similar at different scales, although the self-
similarity might be statistical rather than exact.
The Method for Generating Self-Squaring Fractals (using the Mandelbrot Set as the
primary example):
The Mandelbrot Set is defined by a simple iterative formula in the complex plane:
zn+1=zn2+c
where:
A point c belongs to the Mandelbrot Set if the sequence of absolute values ∣z0∣,∣z1∣,∣z2∣,…
remains bounded (i.e., does not tend to infinity) as n approaches infinity. Typically, if ∣zn∣
exceeds a certain threshold (e.g., 2) at any point during the iteration, it's assumed that the
sequence will go to infinity, and thus c is not in the Mandelbrot Set.
1. Define a region in the complex plane (a rectangular window) that you want to
visualize. This corresponds to a range of real and imaginary values for c.
2. For each pixel in your display window:
o Map the pixel's coordinates to a complex number c.
o Perform the iteration zn+1=zn2+c, starting with z0=0.
o Count the number of iterations (N) until ∣zN∣ exceeds the threshold (e.g., 2) or a
maximum number of iterations (e.g., 100, 1000) is reached.
o Color the pixel based on N:
If the sequence remains bounded (i.e., c is in the Mandelbrot Set), color
the pixel a specific color (e.g., black).
If the sequence diverges, color the pixel based on how quickly it diverged
(i.e., the number of iterations N). A common technique is to use a color
palette that cycles through different hues based on N. This creates the
characteristic beautiful "halos" around the set.