[go: up one dir, main page]

0% found this document useful (0 votes)
50 views81 pages

Computer Graphics

The document discusses various algorithms and concepts in computer graphics, including the Midpoint Circle Algorithm and Bresenham's Line Algorithm for drawing circles and lines efficiently on raster displays. It also covers depth determination for obscuring points using a viewpoint, the Z-buffer algorithm for rendering, and shearing transformations in 2D graphics. Additionally, it explains point clipping and the Cohen-Sutherland line clipping procedure for managing graphical objects within a defined clip window.

Uploaded by

Marzia Borno
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views81 pages

Computer Graphics

The document discusses various algorithms and concepts in computer graphics, including the Midpoint Circle Algorithm and Bresenham's Line Algorithm for drawing circles and lines efficiently on raster displays. It also covers depth determination for obscuring points using a viewpoint, the Z-buffer algorithm for rendering, and shearing transformations in 2D graphics. Additionally, it explains point clipping and the Cohen-Sutherland line clipping procedure for managing graphical objects within a defined clip window.

Uploaded by

Marzia Borno
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

PART –A

Question Solve-2020

Question 1

(a) State and explain the midpoint circle algorithm.

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:

If the current point is (x k ,y k),

the two candidate pixels for the next step are (x k+1,y k) and (x k +1,y k −1).

The midpoint between these two candidates is (x k +1,y k −0.5).

We define a function F(x,y)=x 2 +y 2−r 2.

For points on the circle, F(x,y)=0. For points inside, F(x,y)<0. For points outside, F(x,y)>0.

The decision parameter p k is calculated by evaluating F(x k+1,y k−0.5).

If p k<0, the midpoint is inside the circle or on the boundary. We choose the pixel (x k+1,y k ).

The next decision parameter p k+1 =p +2x k+3.

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:

Start point (x 0 ,y 0)=(20,10)

End point (x 1 ,y1)=(30,18)

Calculations:

Δx=x 1 −x 0 =30−20=10

Δy=y 1−y0 =18−10=8

Since Δx>Δy, we iterate along the x-axis.

Initial decision parameter: p0=2Δy−Δx=2(8)−10=16−10=6

Bresenham's Line Algorithm Steps:

K Current Point (x k ,y k )p k

Next Point (x k+ ,y k+1 )p k+1(if p k <0)

p k+1 (if p ≥0)

0(20, 10)(21, 11)

p +2Δy−2Δx=6+16−20=21
(21, 11)2(22, 12)

p 1+2Δy−2Δx=2+16−20=−2

2(22, 12)-2(23, 12)

p 2+2Δy=−2+16=14

3(23, 12)14(24, 13)

p 3+2Δy−2Δx=14+16−20=10

4(24, 13)10(25, 14)

p 4+2Δy−2Δx=10+16−20=6

5(25, 14)6(26, 15)

p 5+2Δy−2Δx=6+16−20=2

6(26, 15)2(27, 16)

p 6+2Δy−2Δx=2+16−20=−2

7(27, 16)-2(28, 16)

p 7+2Δy=−2+16=14

8(28, 16)14(29, 17)

p 8 +2Δy−2Δx=14+16−20=10

9(29, 17)10(30, 18)

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.

A point P(x,y,z) is obscured by another point Q(x ′ ,y ′ ,z ′ )

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.

Vector from C to P1: CP 1=P 1−C=(1−0,2−0,0−(−10))=(1,2,10)

Vector from C to P2: CP 2 =P 2 −C=(3−0,6−0,20−(−10))=(3,6,30)

Vector from C to P3: CP 3=P 3 −C=(2−0,4−0,6−(−10))=(2,4,16)

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 given transformation matrix is T=( 1 b1).

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:

P ′=P⋅( 1ba ) or P ′ =( 1ba1 )⋅

P T. We typically use column vectors for points in graphics.

Let the transformation matrix be M=( 1ba1 ).

Given a=2 and b=3, the transformation matrix is M=( 1321 ).

The square has vertices:

A = (0,0)

B = (1,0)

C = (1,1)

D = (0,1)

Let's apply the transformation P ‘ =M⋅P T to each point:

For A(0,0):

A ′ =( 1321 )( 00 )=( 00 )

So, A' = (0,0)

For B(1,0):

B ′ =( 1321 )( 10 )=( 1⋅1+2⋅03⋅1+1⋅0 )=( 13 )

So, B' = (1,3)

For C(1,1):C ′=( 13

21 )(11 )=( 1⋅1+2⋅13⋅1+1⋅1 )=( 34 )


So, C' = (3,4)

For D(0,1):

D ′ =( 1321 )( 01 )=( 1⋅0+2⋅13⋅0+1⋅1 )=( 21 )

So, D' = (2,1)

Illustrating the effect:

Original Square:

A = (0,0)

B = (1,0)

C = (1,1)

D = (0,1)

This is a unit square with its bottom-left corner at the origin.

Transformed Shape (Parallelogram):

A' = (0,0)

B' = (1,3)

C' = (3,4)

D' = (2,1)

The transformation has converted the square into a parallelogram.

The x-coordinates are shifted based on their y-value (x-shear): x ′ =x+ay.

The y-coordinates are shifted based on their x-value (y-shear): y ′=bx+y.

Let's verify these with the calculated points:

A(0,0) → A'(0,0): x ′=0+2(0)=0, y ′=3(0)+0=0.

Correct.

B(1,0) → B'(1,3): x ′=1+2(0)=1, y ′ =3(1)+0=3.

Correct.

C(1,1) → C'(3,4): x ′ =1+2(1)=3, y ′ =3(1)+1=4.


Correct.

D(0,1) → D'(2,1): x ′=0+2(1)=2, y ′ =3(0)+1=1.

Correct.

Visual Representation:

(Imagine a coordinate plane)

Original Square:

Connect points (0,0)-(1,0)-(1,1)-(0,1)-(0,0).

It's a square aligned with the axes.

Transformed Parallelogram:

Connect points (0,0)-(1,3)-(3,4)-(2,1)-(0,0).

The bottom edge A'B' is from (0,0) to (1,3).

The right edge B'C' is from (1,3) to (3,4).

The top edge C'D' is from (3,4) to (2,1).

The left edge D'A' is from (2,1) to (0,0).

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) Condition for point clipping:

A point (x, y) is considered inside the clip window if it satisfies the following inequalities:

x_min <= x <= x_max

y_min <= y <= y_max

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.

(c) Cohen-Sutherland line clipping procedure:

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:

Bit 1 (left): if x < x_min

Bit 2 (right): if x > x_max

Bit 3 (bottom): if y < y_min

Bit 4 (top): if y > y_max

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.

The algorithm uses the following to calculate intersection points:

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.

Example: Intersection with the left boundary (x = x_min):

y = y1 + m * (x_min - x1)

where m = (y2 - y1) / (x2 - x1)

Similarly, for other boundaries.


The process continues until the line is either accepted or rejected.

*Question 4:*

(a) Torus in 3D object representations:

A torus is a doughnut-shaped 3D object. It is a surface of revolution generated by revolving a circle in


3D space about an axis that is coplanar with the circle but does not intersect it. The resulting surface is a
ring with a circular cross-section.

Mathematically, a torus can be defined by the equation:

(R - sqrt(x^2 + y^2))^2 + z^2 = r^2

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.

(b) Definitions for spline curve:

- 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.

(c) Cardinal splines for interpolating piecewise cubics:

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:

- The tangent at a control point P_k is calculated as:

T_k = (1 - t) * (P_{k+1} - P_{k-1})

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]

where the coefficients are computed as:

s_0 = P_k

s_1 = T_k

s_2 = 3(P_{k+1} - P_k) - 2*T_k - T_{k+1}

s_3 = 2(P_k - P_{k+1}) + T_k + T_{k+1}

Alternatively, the cardinal spline can be represented in matrix form.

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

(a) Condition for point clipping

A point (x,y)(x,y) is inside the clip window if it satisfies:

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.

(c) Cohen-Sutherland Line Clipping Procedure

This algorithm clips lines against a rectangular window using region codes for endpoints:

Assign 4-bit region codes to endpoints

P1 P1 and P2 P2 :Bit 1 (left): Set if X < xmin X < x min

Bit 2 (right): Set if x > xmax x > x max

Bit 3 (bottom): Set if Y < ymin y < y min


Bit 4 (top): Set if y> ymax y>y max

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.

Non-Trivial Case: For partially visible lines:

Choose an endpoint with a non-zero code.

Calculate the intersection point with the nearest window boundary.

Replace the endpoint with the intersection point and update the region code.

Repeat until the line is accepted or rejected.

Key Insight: Efficiently handles lines by leveraging simple bitwise operations and iterative clipping
against boundaries.

Solution to Question 4

(a) Torus in 3D Representations

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.

Minor Radius (rr): Radius of the tube.

Equation: (R−x2+y2)2+z2=r2(R− x 2+y 2 ) 2 +z 2=r 2 .

(b) Definitions for Spline Curves

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.

(c) Cardinal Splines for Piecewise Cubic Interpolation

Cardinal splines interpolate control points using piecewise cubic polynomials, ensuring C1 C1continuity.
Key features:

Control Points: Four points


(Pk−1,Pk,Pk+1,Pk+2)(P k−1 ,P k ,P k+1 ,P k+2) define each cubic segment between PkP k and Pk+1P k+1 .

Tangent at PkP k :Tk=(1−t)(Pk+1−Pk−1)T k =(1−t)(P k+1−P k−1 )

where ,t (tension parameter) controls curve "tightness" (0≤t≤10≤t≤1).

Parametric Cubic Segment (fromPkP k to Pk+1P k+1):

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:

Interpolation: Passes through PkP k and k1P k+1 .

Tension Adjustment: Lower tt → looser curve; higher tt → tighter curve.

Local Control: Changing a control point affects only adjacent segments.

Advantage: Smooth interpolation with intuitive tension control.

Answers are concise yet comprehensive, covering all subparts as specified in the exam question.

Question solve -2016

Question 1: Line Drawing Algorithms

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.

Understanding Bresenham's Algorithm:

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.

Steps for Bresenham's Algorithm (m < 1):

Initialize:

Plot the starting point (x 0,y 0)=(20,10).

Δx=x 1−x 0 =30−20=10

Δy=y 1−y 0=18−10=8P 0 =2Δy−Δx=2(8)−10=16−10=6

Iterate and Plot:


For k=0 to Δx−1:

If P k<0:x k+1=x k+1y k+1=y kP k+1=P k +2Δy

Else (P k≥0):x k+1=x k+1y k+1=y k+1P k+1=P k +2Δy−2Δx

Plot (x k+1,y k+1 )

Digitization Table:K Current (x k,y k)pkP k <0?

Next (x k+1,y k+1 )

0 (20, 10) 6 No (21, 11)

1 (21, 11) 6+2(8)−2(10)=6+16−20=2 No (22, 12)

2 (22, 12) 2+2(8)−2(10)=2+16−20=−2 Yes (23, 12)

3 (23, 12) −2+2(8)=14 No (24, 13)

4 (24, 13) 14+2(8)−2(10)=14+16−20=10 No (25, 14)

5 (25, 14) 10+2(8)−2(10)=10+16−20=6 No (26, 15)

6 (26, 15) 6+2(8)−2(10)=6+16−20=2 No (27, 16)

7 (27, 16) 2+2(8)−2(10)=2+16−20=−2 Yes (28, 16)

8 (28, 16) −2+2(8)=14 No (29, 17)

9 (29, 17) 14+2(8)−2(10)=14+16−20=10 No (30, 18)

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).

1. b) Explain midpoint circle drawing algorithm.

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:

Start point: (x,y)=(0,r)

Decision parameter: P=1−r (or P=5/4−r for integer coordinates)

Iterate and Plot:

While x<y:

Plot (x,y) and its symmetric points in all eight octants:

(x,y), (−x,y), (x,−y), (−x,−y)

(y,x), (−y,x), (y,−x), (−y,−x)

If P<0 (Midpoint is inside the circle):

Next point is (x+1,y)

Update decision parameter: P=P+2x+3

Else (P≥0 (Midpoint is outside or on the circle):

Next point is (x+1,y−1)

Update decision parameter: P=P+2x−2y+5

Increment x: x=x+1

Decrement y (only if P≥0 in the previous step): y=y−1

End: When x≥y, the algorithm stops. The last remaining symmetric points are plotted.

Advantages:

Uses only integer arithmetic, making it fast.

Avoids floating-point calculations and square roots.

Generates smooth circles.

Question 2: Projections and Transformations

2. a) Classify the projections. Explain the properties of each.

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.

Sub-classifications of Parallel Projections:

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.

Dimetric: Two of the three axes are equally foreshortened.

Trimetric: All three axes are foreshortened by different amounts.

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.

II. Perspective Projections:


In perspective projections, the projection lines converge to a single point called the "center of
projection" or "view point." This mimics how the human eye perceives objects, where distant objects
appear smaller.

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.

Sub-classifications of Perspective Projections (based on the number of vanishing points):

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.

Basic Transformation Techniques used in Window-to-Viewport Transformation:

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.

Derivation of the Viewing Transformation Matrix:

Let's define:

Window Coordinates: (X w,Y w)

Window lower-left corner: (X w min,Y w min )

Window upper-right corner: (X w max,Y w max)

Viewport Coordinates: (X v,Y v )

Viewport lower-left corner: (X v min,Y v min )

Viewport upper-right corner: (X v max,Y v max )

The transformation from window to viewport can be achieved in three steps:

Step 1: Translate the window so that its lower-left corner coincides with the origin.

The translation factors are −X

w minand −Y wmin .

The translation matrix T 1is:T 1= 10001−X w min−Y w min1

After this translation, a point (X w,Y w) becomes (X w−X w min,Y w−Y w min).

Step 2: Scale the translated window to the size of the viewport.

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.

The translation factors are X v minand Y v min.

The translation matrix T 2is:T2=100 010Xv minY v min1

Combined Transformation Matrix:


The overall viewing transformation matrix M wv is the product of these individual transformation
matrices, applied in reverse order:

M wv=T 2⋅S⋅T 1mwv= 100010X v minY v min1⋅ S x000S y0001⋅

100010−X wmin −Y w min1

First, multiply S⋅T 1:S⋅T 1 = S x000S y0−SxX w min−S yY w min1

Now, multiply T 2⋅

(S⋅T 1):M wv=100010 X v minY v min1⋅

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

So, the transformed viewport coordinates (X V,Y v )

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

2. c) Explain why it is essential that clipping take place before projection.

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.

Handling Perspective Distortion:

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.

Simplifying Z-Buffering and Hidden Surface Removal:

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:

a) With neat diagram, explain 2D general pivot point rotations.

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).

2. Rotate the object by the desired angle θ about the origin.

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:

T(tx, ty) = [1, 0, tx; 0, 1, ty; 0, 0, 1] for translation.

R(θ) = [cosθ, -sinθ, 0; sinθ, cosθ, 0; 0, 0, 1] for rotation.


So the composite matrix is:

[1, 0, x_r] [cosθ, -sinθ, 0] [1, 0, -x_r]

[0, 1, y_r] * [sinθ, cosθ, 0] * [0, 1, -y_r]

[0, 0, 1 ] [ 0, 0, 1] [0, 0, 1 ]

Multiplying the last two first (R(θ) * T(-x_r, -y_r)):

[cosθ, -sinθ, 0] [1, 0, -x_r] [cosθ, -sinθ, -x_r*cosθ + y_r*sinθ]

[sinθ, cosθ, 0] * [0, 1, -y_r] = [sinθ, cosθ, -x_r*sinθ - y_r*cosθ]

[ 0, 0, 1] [0, 0, 1] [ 0, 0, 1 ]

Then multiply by T(x_r, y_r):

[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 ]

This can be written as:

[cosθ, -sinθ, x_r*(1 - cosθ) + y_r*sinθ]

[sinθ, cosθ, y_r*(1 - cosθ) - x_r*sinθ]

[ 0, 0, 1 ]

b) Draw a diagram to illustrate reflection of an object with respect to the line y = x.

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]

So, a point (x, y) becomes (y, x).

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).

2. Rotate about the x-axis by the desired angle θ.

3. Translate back by (0, d).

The transformation matrix is:

T(0, d) * R_x(θ) * T(0, -d)

Where R_x(θ) is the rotation matrix about the x-axis:

[1, 0, 0, 0]

[0, cosθ, -sinθ, 0]

[0, sinθ, cosθ, 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.

So, for 3D:

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.

2. Rotate about the x-axis by angle θ.

3. Translate back by (0, d, 0).

The transformation matrix (in 3D) is:


[1, 0, 0, 0] [1, 0, 0, 0] [1, 0, 0, 0]

[0, 1, 0, d] * [0, cosθ, -sinθ, 0] * [0, 1, 0, -d]

[0, 0, 1, 0] [0, sinθ, cosθ, 0] [0, 0, 1, 0]

[0, 0, 0, 1] [0, 0, 0, 1] [0, 0, 0, 1]

But note: the translation matrices are:

T(0,d,0) = [1,0,0,0; 0,1,0,d; 0,0,1,0; 0,0,0,1]

T(0,-d,0)= [1,0,0,0; 0,1,0,-d; 0,0,1,0; 0,0,0,1]

And R_x(θ) = [1,0,0,0; 0,cosθ,-sinθ,0; 0,sinθ,cosθ,0; 0,0,0,1]

So the composite matrix is:

T(0,d,0) * R_x(θ) * T(0,-d,0) =

[1,0,0,0] [1,0,0,0] [1,0,0,0]

[0,1,0,d] * [0,cosθ,-sinθ,0] * [0,1,0,-d]

[0,0,1,0] [0,sinθ,cosθ,0] [0,0,1,0]

[0,0,0,1] [0,0,0,1] [0,0,0,1]

First, multiply R_x(θ) * T(0,-d,0):

[1,0,0,0] [1,0,0,0] [1,0,0,0]

[0,cosθ,-sinθ,0] * [0,1,0,-d] = [0,cosθ,-sinθ, -d*cosθ]

[0,sinθ,cosθ,0] [0,0,1,0] [0,sinθ,cosθ, -d*sinθ]

[0,0,0,1] [0,0,0,1] [0,0,0,1]

Then multiply by T(0,d,0):

[1,0,0,0] [1,0,0,0] [1,0,0,0]

[0,1,0,d] * [0,cosθ,-sinθ, -d*cosθ] = [0,cosθ,-sinθ, -d*cosθ + d]

[0,0,1,0] [0,sinθ,cosθ, -d*sinθ] [0,sinθ,cosθ, -d*sinθ]

[0,0,0,1] [0,0,0,1] [0,0,0,1]

So the composite matrix is:


[1, 0, 0, 0]

[0, cosθ, -sinθ, d(1 - cosθ)]

[0, sinθ, cosθ, -d*sinθ]

[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:

- Step 1: Translation by (0, -d, 0) moves the axis to the x-axis.

- Step 2: Rotation about the x-axis by θ.

- Step 3: Translation by (0, d, 0) moves the axis back.

Now, moving to Question 4.

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:

- Bit 1 (left): if x < x_min

- Bit 2 (right): if x > x_max

- Bit 3 (below): if y < y_min

- Bit 4 (above): if y > y_max

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).

Sutherland-Hodgeman algorithm for polygon clipping:

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.

Steps for 2D (clipping against a rectangular window):

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.

- If both are outside, output nothing.

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.

Note: The order of boundaries can be left, right, bottom, top.

The algorithm works for convex clipping regions and produces a single closed polygon.

c) Distinguish between Cohen-Sutherland and Sutherland-Hodgeman algorithms.

- Cohen-Sutherland is for line clipping, while Sutherland-Hodgeman is for polygon clipping.


- Cohen-Sutherland uses region codes to trivially accept or reject lines and then finds intersection points
with the boundaries. It clips one line segment at a time.

- 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.

Thus, we have answered questions 3 and 4.

Solution to Question 3

a) 2D General Pivot Point Rotation

Rotating an object about an arbitrary pivot point (xr,yr)(x r ,y r ) involves three steps:

Translate the object so the pivot point moves to the origin:T(−xr,−yr)=[10−xr01−yr001]

T(−x r,−y r )= 100010−xr−y r1

Rotate the object by angle θ

θ about the origin:R(θ)=[cos⁡θ−sin⁡θ0sin⁡θcos⁡θ0001]

R(θ)= cosθsinθ0−sinθcosθ0 001

Translate the object back to the original pivot point:T(xr,yr)=[10xr01yr001]

T(x r,y r)= 100010x ry r1

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

a) Cohen-Sutherland Line Clipping Algorithm StepsAssign Region Codes:

4-bit code for each endpoint:Bit 1: Above window (y>ymaxy>y max)


Bit 2: Below window (Y<yminy<y min )

Bit 3: Right of window (x>xmaxx>x max )

Bit 4: Left of window (x<xminx<x min)

Trivial Acceptance: Both endpoints have code 0000 → accept the line.

Trivial Rejection: Bitwise AND of codes ≠ 0000 → reject the line.

Clipping: For a non-trivial line:

Pick an endpoint outside the window.

Find intersection with the nearest window edge.

Replace the endpoint with the intersection point.

Repeat until the line is accepted/rejected.

b) Canonical Viewing Space & Sutherland-Hodgeman Algorithm

Canonical Viewing Space:

A normalized coordinate system where the view volume is a unit cube ([−1,1]3[−1,1] 3).

Simplifies clipping and projection.

Sutherland-Hodgeman Algorithm (for polygon clipping):

Clip Against Left Edge (x=xminx=x min):

For each polygon edge (vi to vi1)(vI to vi+1):

If both vertices inside: keep vi+1 v i+1 .

If inside → outside: keep intersection.

If outside → inside: keep intersection and vi+1vi+1 .

If both outside: keep nothing.

Repeat for right (x=xmaxx=xmax ), bottom (y=yminy=y min), and top (y=ymaxy=y max ) edges.

Output: Final list of vertices forms the clipped polygon.

c) Cohen-Sutherland vs. Sutherland-Hodgeman

Feature Cohen-Sutherland Sutherland-Hodgeman


Purpose Line Clipping Polygon Clipping

Output Single line segment Convex polygon

Handling Curves No (only lines) Yes (via vertex processing)

ComplexityO(1)

O(1) per line O(n)O(n) per edge

Trivial Acceptance Uses region codes Not applicable

Clipping Order Arbitrary window edges Fixed (left→right→bottom→top)

Question solve-2019

1.a) State and explain Bresenham's line generation algorithm.

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.

Midpoint Circle Drawing Algorithm (First Octant):

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.

Given: Radius r=10

Initialization:

 Start point: (x0,y0)=(0,r)=(0,10)


 Initial decision parameter: P0=1−r=1−10=−9

Iteration: We iterate as long as x≤y.

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

Pixels in the first octant (from x=0 to y=x) are:

(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.

Translation: Translation is a rigid-body transformation that moves every point of an object by


the same distance in a given direction. It slides an object from one position to another without
changing its orientation or size.

 Mathematical Representation: If a point P(x,y) is translated by a translation vector T(tx


,ty), the new point P′(x′,y′) is given by: x′=x+tx y′=y+ty In matrix form (homogeneous
coordinates):

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.

 Mathematical Representation (about the origin (0,0)): If a point P(x,y) is rotated by an


angle θ about the origin, the new point P′(x′,y′) is given by: x′=xcosθ−ysinθ
y′=xsinθ+ycosθ In matrix form (homogeneous coordinates):

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).

 Mathematical Representation (about the origin (0,0)): If a point P(x,y) is scaled by


scaling factors sx and sy with respect to the origin, the new point P′(x′,y′) is given by:
x′=x⋅sx y′=y⋅sy In matrix form (homogeneous coordinates):

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.

General Pivot-Point Rotation (Two-Dimensional):


When we want to rotate an object around an arbitrary point (not necessarily the origin), we use a
sequence of three 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.

Combined Transformation Matrix: The overall transformation for a point P to P′ is achieved


by multiplying the individual transformation matrices in reverse order of application (from right
to left): M=T2⋅R⋅T1

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.

2.c) Explain how a shearing transformation can be used to modify 3-dimensional


object shapes.

Shearing Transformation in 3D:

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).

Types of 3D Shearing (examples):

1. Shear along X-axis relative to YZ-plane:


o x′=x+shx⋅y+shx⋅z
o y′=y
o z′=z Here, shx is the shear factor. Points shift in the x-direction based on their y
and z coordinates.

x′y′z′1=1000shx100shx0100001xyz1

2. Shear along Y-axis relative to XZ-plane:


o x′=x
o y′=y+shy⋅x+shy⋅z
o z′=z

x′y′z′1=1shy0001000shy100001xyz1

3. Shear along Z-axis relative to XY-plane:


o x′=x
o y′=y
o z′=z+shz⋅x+shz⋅y

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.

3.a) Define window and viewport in 2-dimensional viewing.

 Window: A window in 2D viewing is a rectangular area in world coordinates that defines


the portion of the scene to be displayed. It acts like a "magnifying glass" over the entire
world, selecting what part of the scene is visible. Only objects or parts of objects that fall
within this window are considered for display.
 Viewport: A viewport is a rectangular area on a display device (like a screen or a
monitor) where the contents of the window are mapped and displayed. It specifies where
on the output device the selected portion of the scene will actually appear. The viewport
is defined in device coordinates (e.g., pixels).

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.

3.b) Explain the process of window-to-viewport coordinate transformation.

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:

 Window coordinates: (x_w,y_w)


 Viewport coordinates: (x_v,y_v)
 Window boundaries: (X_w,min,Y_w,min) and (X_w,max,Y_w,max)
 Viewport boundaries: (X_v,min,Y_v,min) and (X_v,max,Y_v,max)

The transformation typically involves three main steps:

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.

3. Translation to Viewport Position: Finally, the scaled coordinates are translated to


match the origin of the viewport.

The transformation equations are:

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.

3.c) Illustrate and explain the Weiler-Atherton polygon clipping algorithm.

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.

Core Idea and Steps:

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):

Imagine a subject polygon (blue) and a clip polygon (red).

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.

Question 4: Curves and Splines

4.a) Define interpolation and approximation splines.

 Interpolation Splines: An interpolation spline is a curve that passes through every


specified control point (or data point). The curve is constrained to exactly hit each of the
given points. The purpose of interpolation is to find a smooth curve that "connects the
dots." When you define an interpolation spline, the curve's shape is entirely determined
by the positions of these control points.

Example: If you have points A, B, C, and D, an interpolation spline will go directly


through A, then B, then C, and then D.

 Approximation Splines: An approximation spline is a curve that comes close to or


approximates a set of control points but does not necessarily pass through them. Instead,
the control points are used to influence the shape and direction of the curve, pulling it
towards them. Approximation splines offer more flexibility in shaping the curve and are
often preferred for interactive design because moving a single control point affects the
curve locally, providing intuitive control.

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.

 C0 (Zeroth-Order) Continuity - Positional Continuity:


o Condition: The endpoint of the first segment must coincide with the start point of
the second segment.
o Mathematical Form: P_1(1)=P_2(0)
o Explanation: This ensures that there are no gaps or breaks in the curve. The
curve is connected, but it might have a sharp corner or a discontinuity in its
tangent (direction). This is the minimum requirement for a continuous curve.
 C1 (First-Order) Continuity - Tangential Continuity:
o Condition: In addition to C0 continuity, the tangent vectors (first derivatives) of
the two segments at the join point must be in the same direction and usually have
the same magnitude (or be proportional).
o Mathematical Form: P_1′(1)=kcdotP_2′(0), where k is a positive scalar constant.
If k=1, the magnitudes are also equal.
o Explanation: This ensures that the curve changes direction smoothly at the join
point, without any sharp corners or kinks. It looks visually smooth. Many
animation paths and smooth object outlines require C1 continuity.
 C2 (Second-Order) Continuity - Curvature Continuity:
o Condition: In addition to C1 continuity, the second derivatives (accelerations or
rates of change of tangent) of the two segments at the join point must be equal (or
proportional).
o Mathematical Form: P_1′′(1)=kcdotP_2′′(0), where k is a positive scalar
constant.
o Explanation: This ensures that the rate of change of the tangent vector is smooth.
Visually, this means there are no sudden changes in curvature (how sharply the
curve bends). Curves with C2 continuity appear extremely smooth and are often
used in high-quality rendering, automotive design, and aerospace applications
where aesthetic smoothness is critical.
Higher orders of continuity (C3, etc.) exist but are less commonly required in practical computer
graphics, as C2 generally provides sufficient visual smoothness.

4.c) State and explain the Hermite Interpolation.

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

Properties and How it Works:

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

o At t=0: P′(0)=0cdotP_0+0cdotP_1+1cdotR_0+0cdotR_1=R_0. The tangent at the


start point is R_0.
o At t=1: P′(1)=0cdotP_0+0cdotP_1+0cdotR_0+1cdotR_1=R_1. The tangent at the
end point is R_1.

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:

Hermite interpolation is widely used in computer graphics for:

 Animation path generation: To create smooth camera movements or object trajectories.


 Font design: Defining the outlines of characters.
 Surface modeling: As components of more complex patch definitions (e.g., bicubic
Hermite surfaces).
 Interactive curve design: Allowing users to intuitively shape curves by manipulating
points and tangent handles.

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

Let's address each line segment separately:

Segment 1: (4,0) to (20,10)

 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)

Segment 2: (30,18) with a shape of 0.8 with Δx = 10 and Δy = 8

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:

k p_k (x_{k+1}, y_{k+1})

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?

Midpoint Circle Drawing Algorithm Explanation:


The Midpoint Circle Drawing Algorithm (also known as Bresenham's circle algorithm) is an
efficient algorithm for drawing circles. It works by determining the next pixel to plot based on
the sign of a decision parameter. This parameter helps choose between two candidate pixels that
are closest to the ideal circle path. The algorithm exploits the 8-way symmetry of a circle,
calculating only the points for one octant (e.g., from (0, radius) to (radius/sqrt(2), radius/sqrt(2)))
and then mirroring them to generate the full circle.

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)

Advantages of Midpoint Circle Drawing Algorithm:

 Efficiency: It uses only integer arithmetic (additions, subtractions, and multiplications by


2, which can be implemented as bit shifts), avoiding computationally expensive floating-
point operations like square roots or trigonometric functions, which are common in
parametric or direct equation methods.
 Speed: Due to its integer-only operations, it's very fast, making it suitable for real-time
graphics applications.
 Accuracy: It chooses the pixel closest to the true circle path, resulting in smooth and
accurate circle approximations.
 Simplicity: The logic is relatively straightforward to implement compared to methods
that require extensive floating-point calculations or look-up tables.
 No Division: Unlike some other algorithms that might involve division (e.g., from slope
calculations), the Midpoint algorithm avoids it, further contributing to its speed.
Question 2: 2-Dimensional Composite Transformation

2.a) In 2-Dimensional composite transformation, when concatenating successive scaling


operations, the resulting output is "Additive" or "Multiplicative" ?

When concatenating successive scaling operations in 2-D composite transformation, the resulting
output is Multiplicative.

Explanation:

A scaling transformation is represented by a scaling matrix:

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.

2.b) With neat diagrams, explain 2D General Pivot-point Rotation.

2D General Pivot-point Rotation Explanation:

A general pivot-point rotation (also known as arbitrary pivot-point rotation) is a rotation of an


object around a specified point (x_p,y_p) that is not necessarily the origin (0,0).

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:

Let's illustrate with an object (e.g., a triangle) and a pivot point P.

Initial State:

A
/ \
/ \
B-----C
.
. P(xp, yp)

Step 1: Translate Pivot to Origin

The entire object is translated so that P is now at (0,0).

A'
/ \
/ \
B'----C'
.
P'(0,0)

 Transformation: T(−x_p,−y_p)

Step 2: Rotate Around Origin

The object is rotated around the new origin (which was P).

A''
/ \
/ \
C''---B''
.
P''(0,0)

 Transformation: R(θ)

Step 3: Translate Pivot Back

The object is translated back, moving P to its original position.

A'''
/ \
/ \
C'''--B'''
.
. P'''(xp, yp)

 Transformation: T(x_p,y_p)

Combined Transformation Matrix (M_pivot_rotation):

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.

Concept of Point Reflection (through P):

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

This is equivalent to:

1. Translate P to the origin.


2. Reflect through the origin (multiply x and y by -1).
3. Translate back P to its original position.

Diagram:

Let's take a simple object like a triangle ABC and a point P.

Initial State:

A
/ \
/ \
B-----C
.
P

Reflected State (through point 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).

3D Scaling with Respect to a 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:

Let's consider a 3D object like a cube and a fixed scaling point P.

Initial State:

Imagine a cube in 3D space.

Z
^
|
| C2-----D2 (top face)
| /| /|
| B2--A2 |
| | | |
| | C1-|--D1 (bottom face)
| | / | /
| A1----B1
+----------------> Y
/
/
X
. P(xf, yf, zf)

Step 1: Translate Fixed Position to Origin

The entire cube is translated so that P is now at (0,0,0).


Z
^
|
| C2'-----D2'
| /| /|
| B2'--A2' |
| | | |
| | C1'-|--D1'
| | / | /
| A1'----B1'
+----------------> Y
/
/
X
P'(0,0,0)

 Action: Move P to the origin.

Step 2: Scale Object at Origin

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)

 Action: Apply scaling factors (s_x,s_y,s_z).

Step 3: Translate Fixed Position Back

The scaled cube is translated back, moving P to its original position.

Z
^
|
| C2'''----D2'''
| /| /|
| B2'''--A2''' |
| | | |
| | C1'''-|--D1'''
| | / | /
| A1'''---B1'''
+----------------> Y
/
/
X
. P'''(xf, yf, zf)

 Action: Move P back to its original coordinates.

Combined Transformation Matrix (M_fixed_point_scaling):

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)

3.a) What is transformation? Explain the difference between geometric transformations


and 3.00 coordinate transformation.

What is Transformation?

In computer graphics, a transformation refers to the process of changing the position,


orientation, or size of an object. It's a fundamental concept used to manipulate objects within a
scene, enabling animation, viewing from different perspectives, and object rearrangements.
Transformations are typically represented by mathematical operations (usually matrix
multiplications) applied to the coordinates of the object's vertices.

Difference between Geometric Transformations and Coordinate 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.

1. Geometric Transformations (Object Transformations):


o What it is: This refers to changing the position, orientation, or size of the object
itself relative to a fixed coordinate system (often the world coordinate system).
The object moves, rotates, or scales, but the coordinate system axes remain
stationary.
o How it works: You apply transformation matrices to the coordinates of the
object's vertices. The points of the object are effectively moved to new locations
in the space.
o Analogy: Imagine moving, rotating, or resizing a physical object in a room. The
room (coordinate system) stays the same, but the object's position within it
changes.
o
Examples: Translation (moving an object), Rotation (spinning an object), Scaling
(resizing an object), Reflection (mirroring an object), Shearing (distorting an
object).
2. Coordinate Transformation (Viewpoint Transformations):
o What it is: This refers to changing the coordinate system itself relative to a fixed
object. The object remains stationary, but its coordinates are re-expressed with
respect to a new coordinate system. This is often used to change the "viewpoint"
or perspective from which an object is observed.
o How it works: You apply transformation matrices to the coordinate system's
basis vectors or origin. Essentially, you're changing the frame of reference.
o Analogy: Imagine you are standing in a room (the object is fixed). If you walk
around the room, the objects in the room don't move, but their coordinates relative
to you (your personal coordinate system) change.
o Examples: Changing from world coordinates to camera coordinates (viewing
transformation), or from object coordinates to world coordinates.

Key Difference Summary:

Feature Geometric Transformation Coordinate Transformation

What changes? The object's position/orientation/size The coordinate system/frame of reference

Reference Relative to a fixed coordinate system Relative to a fixed object

Primary Use Manipulating objects Changing viewpoint or representation

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).

Let's break this down into two separate rotation problems.

Part 1: 60° Rotation about the Origin

 Rotation Angle: θ=60∘


 Rotation Matrix R(θ) about the origin: R(θ)=(cosθsinθ−sinθcosθ) For θ=60∘:
cos(60∘)=0.5 sin(60∘)=23≈0.866 So, R(60∘)=(0.50.866−0.8660.5)
 Vertices:
o A = (1, 1)
o B = (11, 2)
o C = (5, 5)
 Applying the rotation: For a point (x,y), the new point (x′,y′) is given by:
x′=xcosθ−ysinθ y′=xsinθ+ycosθ
o For A(1,1): Ax′=1⋅0.5−1⋅0.866=0.5−0.866=−0.366 Ay′
=1⋅0.866+1⋅0.5=0.866+0.5=1.366 A′=(−0.366,1.366)
o For B(11,2): Bx′=11⋅0.5−2⋅0.866=5.5−1.732=3.768 By′
=11⋅0.866+2⋅0.5=9.526+1.0=10.526 B′=(3.768,10.526)
o For C(5,5): Cx′=5⋅0.5−5⋅0.866=2.5−4.33=−1.83 Cy′
=5⋅0.866+5⋅0.5=4.33+2.5=6.83 C′=(−1.83,6.83)

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).

 Rotation Angle: θ=60∘


 Pivot Point: P=(xp,yp)=(−1,0)
 Vertices:
o A = (1, 1)
o B = (11, 2)
o C = (5, 5)
 Steps for Rotation about an Arbitrary Pivot Point:

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)

The combined transformation for a point (x,y) to (x′,y′) is: x′=(x−xp)cosθ−(y−yp)sinθ+xp


y′=(x−xp)sinθ+(y−yp)cosθ+yp

With θ=60∘, cos(60∘)=0.5, sin(60∘)=0.866, and (xp,yp)=(−1,0):


x′=(x−(−1))⋅0.5−(y−0)⋅0.866+(−1) x′=(x+1)⋅0.5−y⋅0.866−1

y′=(x−(−1))⋅0.866+(y−0)⋅0.5+0 y′=(x+1)⋅0.866+y⋅0.5

o For A(1,1): Ax′=(1+1)⋅0.5−1⋅0.866−1=2⋅0.5−0.866−1=1−0.866−1=−0.866 Ay′


=(1+1)⋅0.866+1⋅0.5=2⋅0.866+0.5=1.732+0.5=2.232 A′=(−0.866,2.232)
o For B(11,2): Bx′=(11+1)⋅0.5−2⋅0.866−1=12⋅0.5−1.732−1=6−1.732−1=3.268 By′
=(11+1)⋅0.866+2⋅0.5=12⋅0.866+1=10.392+1=11.392 B′=(3.268,11.392)
o For C(5,5): Cx′=(5+1)⋅0.5−5⋅0.866−1=6⋅0.5−4.33−1=3−4.33−1=−2.33 Cy′
=(5+1)⋅0.866+5⋅0.5=6⋅0.866+2.5=5.196+2.5=7.696 C′=(−2.33,7.696)

3.c) How can you create a mirror image of a 2D object?

To create a mirror image of a 2D object, you perform a reflection transformation. Reflection is


a transformation that produces a mirror image of an object relative to an axis of reflection (a
line).

There are typically three common scenarios for reflection in 2D:

1. Reflection about the x-axis:


o The x-coordinate remains the same, and the y-coordinate changes sign.
o Transformation Matrix: 1000−10001
o New Point: (x′,y′)=(x,−y)
2. Reflection about the y-axis:
o The y-coordinate remains the same, and the x-coordinate changes sign.
o Transformation Matrix: −100010001
o New Point: (x′,y′)=(−x,y)
3. Reflection about the origin:
o Both x and y coordinates change sign. This is equivalent to a 180-degree rotation
around the origin.
o Transformation Matrix: −1000−10001
o New Point: (x′,y′)=(−x,−y)
4. Reflection about an arbitrary line (y=mx+c or Ax+By+C=0): This is more complex
and involves a sequence of transformations:
o Translate the line so it passes through the origin.
o Rotate the line so it aligns with one of the coordinate axes (e.g., the x-axis).
o Reflect about that coordinate axis.
o Rotate back to the original orientation.
o Translate back to the original position.

For example, reflecting about the line y=x:

o The x and y coordinates are swapped.


o Transformation Matrix: 010100001
o New Point: (x′,y′)=(y,x)

In summary, to create a mirror image of a 2D object, you apply a reflection transformation


matrix to its coordinates, typically across the x-axis, y-axis, or a custom axis.
Question 4: Display Systems and Coordinate Systems

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.

1. Calculate the total number of pixels in each dimension:


o Width of screen = 10 inches
o Height of screen = 8 inches
o Pixels per inch (PPI) = 2.75
o Number of pixels in width = Width (inches) × PPI = 10×2.75=27.5 pixels.
o Number of pixels in height = Height (inches) × PPI = 8×2.75=22 pixels.

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).

Let's assume "100 pixels per inch" is the correct density.

o Number of pixels in width = 10 inches×100 pixels/inch=1000 pixels


o Number of pixels in height = 8 inches×100 pixels/inch=800 pixels
2. Calculate the total number of pixels on the screen:
o Total pixels = Width pixels × Height pixels = 1000×800=800,000 pixels
3. Determine the number of bits per pixel:
o A color lookup table (CLUT) with 64 positions means there are 64 distinct colors
that can be displayed.
o The number of bits required to represent 64 colors is given by
2n=number of colors, where n is the number of bits.
o 2n=64⇒n=log2(64)=6 bits per pixel.
4. Calculate the total frame buffer size in bits:
o Total bits = Total pixels × Bits per pixel =
800,000 pixels×6 bits/pixel=4,800,000 bits
5. Convert the total bits to bytes:
o There are 8 bits in 1 byte.
o Frame buffer size (bytes) = Total bits / 8 = 4,800,000/8=600,000 bytes

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′).

Derivation using "Right Triangles" (Geometric Derivation):

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

Substitute A=ϕ and B=θ:

o For x′: x′=r(cosϕcosθ−sinϕsinθ) x′=(rcosϕ)cosθ−(rsinϕ)sinθ


o For y′: y′=r(sinϕcosθ+cosϕsinθ) y′=(rsinϕ)cosθ+(rcosϕ)sinθ
5. Substitute back Cartesian Coordinates: Recall from step 1 that x=rcosϕ and y=rsinϕ.
Substitute these back into the expressions for x′ and y′:
o x′=(x)cosθ−(y)sinθ x′=xcosθ−ysinθ
o y′=(y)cosθ+(x)sinθ y′=xsinθ+ycosθ

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.

Here's the working principle:

 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.

How Images are Formed (Twisted Nematic - TN LCDs are common):

 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.

b) State and explain Bresenham's Line Drawing Algorithm.

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$):

1. Input: Two endpoints (x_0,y_0) and (x_1,y_1).


2. Calculate Deltax and Deltay: Deltax=∣x_1−x_0∣ Deltay=∣y_1−y_0∣
3. Initialize Decision Parameter (P_k): P_0=2Deltay−Deltax
4. Set Initial Pixel: Plot the starting pixel (x_0,y_0).
5. Loop and Plot Pixels: For each x_k from x_0 to x_1−1:
o If $P\_k \< 0$:
 The line is closer to the pixel at (x_k+1,y_k).
 Plot (x_k+1,y_k).
 Update decision parameter: P_k+1=P_k+2Deltay
o If P_kge0:
 The line is closer to the pixel at (x_k+1,y_k+1).
 Plot (x_k+1,y_k+1).
 Update decision parameter: P_k+1=P_k+2Deltay−2Deltax
o Increment x: x_kgetsx_k+1
o If P_kge0, increment y: y_kgetsy_k+1 (This is implicitly handled by the choice of
which pixel to plot)

Explanation of the Decision Parameter:

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:

a) Define differential scaling.

Differential scaling (also known as non-uniform scaling or anisotropic scaling) is a geometric


transformation that stretches or shrinks an object along different axes by different amounts. In
contrast to uniform scaling, where an object is scaled equally in all dimensions (maintaining its
aspect ratio), differential scaling allows for independent scaling factors along the x, y, and z (if
applicable) axes.

Mathematical Representation:

For a 2D point P(x,y), differential scaling can be represented by a transformation matrix:

(x′y′)=(sx00sy)(xy)

Where:

 s_x is the scaling factor along the x-axis.


 s_y is the scaling factor along the y-axis.

For a 3D point P(x,y,z):

x′y′z′=sx000sy000szxyz
Where:

 s_x, s_y, and s_z are the scaling factors along the x, y, and z axes, respectively.

Effects of Differential Scaling:

 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.

b) With neat diagrams, explain 2D general fixed-point scaling.

2D General Fixed-Point Scaling is a transformation that scales an object about an arbitrary


point (the "fixed point" or "pivot point") in the 2D plane, rather than about the origin. If scaling
were performed directly about the origin, the object would not only change size but also shift its
position relative to its original location. Fixed-point scaling ensures that a specific point on the
object remains stationary during the scaling operation.

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′).

Mathematical Derivation using Transformation Matrices:

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:

Multiplying these matrices:

Tscaling_fixed_point=100010xfyf1sx000sy0001100010−xf−yf1
Tscaling_fixed_point=sx000sy0xfyf1100010−xf−yf1
Tscaling_fixed_point=sx000sy0−sxxf+xf−syyf+yf1

So, the transformation equations for a point (x,y) to (x′,y′) are:

x′=xcdots_x+x_f(1−s_x) y′=ycdots_y+y_f(1−s_y)

Diagrams:

Let's illustrate with a simple rectangle and a fixed point.

Initial State:

(x, y)
+-------+
| |
| R |
| |
+-------+
F(xf, yf) <-- Fixed Point

Step 1: Translate Fixed Point to Origin

Move the entire rectangle such that the fixed point F is now at (0,0).

+-------+
| |
| R' |
| |
+-------+
(0,0) <-- F' (F translated to origin)

Equation for this step: (x−x_f,y−y_f)

Step 2: Scale about the Origin

Now, scale the translated rectangle R' about the origin.

+-----------+
| |
| R'' |
| |
+-----------+
(0,0) <-- F' (still at origin, but now scaled)

Equation for this step: ((x−x_f)cdots_x,(y−y_f)cdots_y)

Step 3: Translate Back to Original Fixed Point Location

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)

Equation for this step: ((x−x_f)cdots_x+x_f,(y−y_f)cdots_y+y_f)

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.

c) Explain the Weiler-Atherton polygon clipping algorithm.

The Weiler-Atherton polygon clipping algorithm is an algorithm used in computer graphics to


clip a subject polygon against a clip polygon. It's particularly notable for its ability to handle
complex polygons (concave, self-intersecting) and clip windows (concave or convex), producing
correct output polygons, including multiple output polygons if the subject polygon is split by the
clip window.

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.

Core Idea: Following Boundaries

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.

Key Steps and Concepts:

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).

Handling Multiple Polygons and Concavity:

 Concave Clip Windows: Weiler-Atherton handles concave clip windows gracefully


because it explicitly checks for "entry" and "exit" points relative to the clip polygon's
interior.
 Multiple Output Polygons: If the subject polygon is completely outside, or entirely
inside, or split by the clip window, the algorithm correctly identifies and generates zero,
one, or multiple output polygons, respectively. This is achieved by systematically visiting
all "entry" points and tracing out the resulting polygon segments.

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:

 Correctly handles concave subject and clip polygons.


 Generates multiple output polygons when the subject polygon is split.
 Robust for complex clipping scenarios.
Disadvantages:

 More complex to implement than simpler algorithms like Sutherland-Hodgman due to


the need for careful tracking of entry/exit points and traversal logic.
 Computational cost can be higher due to intersection calculations and the complex
traversal.

Diagrammatic Representation (Simplified):

Imagine a subject polygon (blue) and a clip polygon (red).

Initial State:

+-------+ (Clip Polygon - Red)


| |
| ____ |
| / \ |
|/_____\| (Subject Polygon - Blue)
| |
+-------+

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:

a) What do you understand by "Blobby" objects?

"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.

How they work:

1. Field Functions (or Potentials): A blobby object is composed of several "primitive"


elements, typically spheres or ellipsoids, each associated with a field function (also
called a potential function). This function describes the influence of that primitive in 3D
space. The value of the field function is high near the center of the primitive and
decreases as you move further away. A common field function is based on an inverse-
square law or a Gaussian falloff. For example, a simple field function for a sphere
centered at (x_c,y_c,z_c) with radius R could be:

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.

b) Define "Convex hull" and "Control polygon".

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.

Key properties and characteristics:

 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):

Imagine a set of scattered points:

. .
.
. .
.
.

The convex hull would be the polygon enclosing all these points:

+-----------+
| |
| . . |
| . |
| |
| . . |
| . |
| . |
+-----------+

The boundary of the polygon is the convex hull.

Control Polygon:

In computer graphics, particularly in the context of splines and Bezier curves/surfaces, a


control polygon (also known as a control polyline or control net for surfaces) is a sequence of
connected line segments (or a grid of connected lines for surfaces) defined by a set of control
points.

Key characteristics and role:

 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).

Diagram (Bezier Curve example):

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.

c) State and explain "Cardinal splines" as an interpolating piecewise cubic polynomials.

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.

Mathematical Formulation (for a segment between P_i and P_i+1):

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

Or more commonly as a blending function:

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).

Explanation using Tangents:

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.

Tangent at P_i: T_i=(1−texttension)cdot(P_i+1−P_i−1)

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.

P0 ------ P1 ------ P2 ------ P3 ------ P4


(Control points)

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:

a) Describe Cohen-Sutherland line clipping algorithm.

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).

o Bit 1 (Most Significant Bit - MSB): Top (T): Set if yY_max


o Bit 2: Bottom (B): Set if $y \< Y\_{min}$
o Bit 3: Right (R): Set if xX_max
o Bit 4 (Least Significant Bit - LSB): Left (L): Set if $x \< X\_{min}$

The region code 0000 means the point is inside the clip window.

2. Clipping Decisions based on Outcodes: Let P_1(x_1,y_1) and P_2(x_2,y_2) be the


endpoints of the line segment, with their respective outcodes C_1 and C_2.
o Case 1: Trivial Accept: If C_1=0000 AND C_2=0000: Both endpoints are inside
the window. The entire line segment is visible. Accept and draw.
o Case 2: Trivial Reject: If (C_1 AND C_2) ne0000: This means both endpoints
share at least one common "outside" region (e.g., both are to the left of the left
boundary, or both are above the top boundary). In this case, the entire line
segment is outside the window and cannot intersect it. Reject and discard.
o Case 3: Clipping Required: If neither trivial accept nor trivial reject applies: The
line segment intersects one or more clip boundaries. This is where actual clipping
takes place.

Clipping Process (for Case 3):

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:

 Fast Trivial Rejection/Acceptance: Quickly discards or accepts many lines, reducing


computation.
 Simple Logic: The use of bitwise operations for outcodes is computationally efficient.

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)

Step 1: Assign Outcodes to P1 and P2

Recall Outcode bits: TBRL (Top, Bottom, Right, Left)

For P1 (70, 20):

 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)

For P2 (100, 10):

 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)

Step 2: Check for Trivial Accept/Reject

 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.

Intersection with Right boundary (x=X_max=80): Use the formula:


y_int=y_1+(y_2−y_1)fracX_max−x_1x_2−x_1 Here, (x_1,y_1)=(70,20) and
(x_2,y_2)=(100,10).

y_int=20+(10−20)frac80−70100−70 y_int=20+(−10)frac1030 y_int=20−10cdotfrac13


y_int=20−frac103 y_int=20−3.333... y_int=16.666...

The intersection point is (80,16.67) (approximately). Let's call this new point P_2′=(80,16.67).

Step 4: Recalculate Outcodes and Repeat

Now the line segment is P1 (70, 20) to P2' (80, 16.67).

Outcode (C1) for P1 (70, 20) = 0000 (still inside)

For P2' (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)

Step 5: Final Check

 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

a) State and explain Bresenham's line-generating algorithm.

Bresenham's line-generating algorithm is an efficient algorithm for drawing a line segment


between two points (x0,y0) and (x1,y1) using only integer arithmetic. It determines the pixels
that best approximate the line by iteratively choosing the next pixel based on a decision
parameter. The algorithm avoids floating-point calculations, making it fast and suitable for
hardware implementation.

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

a) What do you mean by "translation vector" and "differential scaling"?

 Translation Vector: A translation vector, often denoted as T=(tx,ty) in 2D or T=(tx,ty,tz


) in 3D, is a mathematical construct used in computer graphics to represent a rigid body
transformation that moves an object or a point from one position to another without any
rotation, scaling, or shearing. When you apply a translation vector to a point (x,y), the
new coordinates (x′,y′) are simply x′=x+tx and y′=y+ty. In matrix form, using
homogeneous coordinates, a 2D translation is represented as:

x′y′1=100010txty1xy1

The translation vector specifies the amount of shift along each axis.

 Differential Scaling: Differential scaling, also known as non-uniform scaling or


anisotropic scaling, refers to the process of scaling an object by different amounts along
different axes. Unlike uniform scaling, where an object is scaled equally in all directions,
differential scaling can distort the object's shape by elongating or compressing it along
specific dimensions.

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.

b) Discuss the concept of "general fixed point scaling".

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."

The process of general fixed-point scaling involves three main steps:

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.

c) Explain "shear" as a 2D geometric transformation.

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.

There are two common types of 2D shear:

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

a) State and explain Weiler-Atherton Polygon clipping algorithm.

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.

b) What do you mean by "Control graph" and "Control polygon"?

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.

c) Explain the Cardinal Spline interpolation method.

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).

 Tension Parameter (c or τ):


o When c=0 (or τ=1), the spline is a Catmull-Rom spline, which is known for its
ability to produce a "tighter" curve that tends to follow the control points closely.
o As c increases towards 1 (or τ decreases towards 0), the curve becomes "looser"
or "flatter," pulled less tightly by the intermediate points.
o The tension parameter essentially controls the magnitude of the tangent vectors at
each data point.

Advantages:

 Interpolation: The curve passes through all specified data points.


 Smoothness: Produces a visually smooth curve (C1 continuity, meaning both position
and tangent are continuous).
 Local Control: Changing one data point only affects the curve segment(s) immediately
surrounding it.
 Tension Control: The ability to adjust tension provides flexibility in shaping the curve.

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.

Traditional Dimension (Topological Dimension):


 A point has dimension 0.
 A line has dimension 1.
 A plane has dimension 2.
 A cube has dimension 3.

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.

The Concept of Fractal Dimension:

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:

 For a line (1D): N(ϵ)∝(1/ϵ)1


 For a plane (2D): N(ϵ)∝(1/ϵ)2
 For a volume (3D): N(ϵ)∝(1/ϵ)3

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(ϵ)

Explaining Detail Variation with Examples (with Diagrams):

Let's use the Koch Snowflake as an example:

Diagram 1: Iteration 0 (Initial Line Segment)

 Draw a straight line segment.


 This is a 1D object. If you cover it with small segments, N(ϵ)∝1/ϵ. Its topological
dimension is 1.

Diagram 2: Iteration 1 (First Step of Koch Curve)

 Divide the line segment into three equal parts.


 Remove the middle part.
 Add an equilateral triangle where the middle part was, pointing outwards.
 The length has increased. The line is now more "crinkly."

Diagram 3: Iteration 2 (Second Step)

 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.

Diagram 4: Zooming In on the Koch Curve

 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.

Detail Variation and Fractal Dimension:

 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.

Other Examples (Visualize these):

 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:

 z is a complex variable (starts at z0=0).


 c is a complex constant, which is the point in the complex plane that we are testing.

Illustration (Conceptually, for a given c):

1. Choose a point c in the complex plane. (e.g., c=0.5+0.3i)


2. Initialize z0=0.
3. Iterate:
o Calculate z1=z02+c=02+c=c
o Calculate z2=z12+c=c2+c
o Calculate z3=z22+c=(c2+c)2+c
o And so on...

The Rule for Membership in the Mandelbrot Set:

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.

Generating the Fractal Object (The Visualization):

To generate the visual fractal:

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.

You might also like