0% found this document useful (0 votes)
184 views22 pages

CG Theory Assignment

This document contains a final theory assignment for a computer graphics course. It includes: 1) Questions about computer graphics hardware like the differences between raster scan and random scan systems and calculations of frame buffer loading times. 2) Descriptions of algorithms for drawing graphics primitives like lines and circles using techniques like Bresenham's line algorithm and midpoint circle algorithm. 3) Explanations of graphics transformations like translation, scaling, and rotation using 4x4 transformation matrices. 4) An overview of the Cohen-Sutherland line clipping algorithm for clipping lines to a rectangular viewport.

Uploaded by

pinky
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)
184 views22 pages

CG Theory Assignment

This document contains a final theory assignment for a computer graphics course. It includes: 1) Questions about computer graphics hardware like the differences between raster scan and random scan systems and calculations of frame buffer loading times. 2) Descriptions of algorithms for drawing graphics primitives like lines and circles using techniques like Bresenham's line algorithm and midpoint circle algorithm. 3) Explanations of graphics transformations like translation, scaling, and rotation using 4x4 transformation matrices. 4) An overview of the Cohen-Sutherland line clipping algorithm for clipping lines to a rectangular viewport.

Uploaded by

pinky
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/ 22

CG Final Theory Assignment

Name: Bakhtawer

Roll No: 2k19/IT/28


Class: BS IT Part III (Morning)
Subject: Computer Graphics
Assignment: Final Theory Assignment
Teacher: Sir Muhammad Ali Nizamani

1. Computer Graphics Hardware (10 Marks, 2 Marks each)


i) Differentiate between Raster Scan System and Random Scan Systems.

BASIS FOR
RASTER SCAN RANDOM SCAN
COMPARISON

Electron beam Swept across the screen and Directed to the portions of the

handles one row at a time and in screen where a picture is to be

downward direction. rendered.

Resolution Poor, since it generates meander Good, as this produces even

lines which are organized as lines drawing.

distinct point sets.


BASIS FOR
RASTER SCAN RANDOM SCAN
COMPARISON

Picture definition Stored as the combination of Stored as a group of line

intensity values for all screen drawing instructions in a

points. display file.

Realistic display Effectively displays realistic Unable to display realistic

scenes. shaded scenes.

Picture rendering Using pixels With the help of mathematical

functions
iii) How long would it take to load an 800 by 600 frame buffer with 16 bits per pixel, if 105
bits can be transferred per second? How long would it take to load a 32-bit-per-pixel frame
buffer with a resolution of 1680 by 1050 using this same transfer rate?
Let X the time that will be taken to load a 800-by-600 frame buffer with 16 bits per pixel.
Number of bits = 800 * 600 * 16 = 7680000 bits
Then X = 7680000/105 = 73.142 seconds

Let X the time that will be taken to load a 1680-by-1050 frame buffer with 32 bits per pixel.
Number of bits = 1680 * 1050 * 32 = 56448000 bits
Then X = 56448000/105 = 537.600 seconds

iv) Consider two raster systems with resolutions of 800 by 600 and 1680 by 1050. How many pixels could be
accessed per second in each of these systems by a display controller that refreshes the screen at a rate of 60
frames per second? What is the access time per pixel in each system?

a): Pixels access through 800 x 600 resolution:

Pixels / second = (800*600 pixels)*60 frame/second =28800000 pixels / second

Time to access each pixel is 1/28800000 = 0.000000034 seconds

b): Pixels access through 1680 by 1050 resolution:

Pixels / second = (1680 * 1050 pixels) * 60 frame/second = 105840000 pixels / second

Time to access each pixel is 1 / 105840000= 0.00000000944 seconds

v) Suppose we have a video monitor with a display area that measures 12 inches
across and 9.6 inches high. If the resolution is 1280 by 1024. Find its aspect ratio,
pixels per inch (PPI) and the Dot Pitch.

1) Find Aspect Ratio:


Divide width by height
1280/1024 = 1.25
Aspect ratio = 1.25:1

2) Find Pixels Per Inch (PPI):


Calculate number of pixels that fit on diagonal
d0 = √ (w2 + h2)
= √ (12802 + 10242)
d0 = 1639

PPI = d0/di (diagonal in inches)


Determine diagonal in inches from given width and height
di = √ (122 + 9.62)
di = 15.36

PPI = 1639/15.36
PPI = 106.7

3) Find Dot Pitch:


Distance between two pixels’ centers, calculated as the inverse of PPI
Dot Pitch = 1 inch/PPI
1 inch = 25.4 mm
Dot Pitch = 25.4 mm / 106.7
Dot Pitch = 0.238 mm

2. Implementation Algorithms for Graphics Primitives and Attributes [10 Marks] i)


Describe Key features Line Drawing Algorithm used in computer graphics

• The line is drawn in the form of pixels in the computer system


• In this the line would be shown along its length with steady visibility, regardless of its distance and the
direction of the line.
• With the help of a line drawing algorithm we can easily draw the line in the computer system.
• We can use Bresenham's and DDA Line Algorithm to draw the line in the computer system these two
algorithms have a different method to implement the line.

ii) How is circle drawing different then line drawing. Use the midpoint method to derive decision
parameters that can be used to generate a circle.
Line drawing algorithm:
Line algorithm determines the points of a raster that have to be selected to form an approximate line between
two points. It also uses integer addition bit shifting and subtraction. It is also one of the earliest algorithms.
Circle drawing algorithm:
On the other hand, circle drawing algorithm prevents trigonometric calculations and only use adopting integers.
It also uses the floating point calculations. This algorithm checks the nearest integer by calculating the midpoint
of the pixels nearer to the given point on the circle.
Derivation of Decision parameter:
Decision parameter is based on circle equation.
Let the center circle is (0,0)
So the equation of circle is x2 + y2 = z2
Let us define the function of a circle fcircle(x+y) = x2 + y2 = z2
If fcircle < 0 then x y is inside the circle boundary.
If fcircle > 0 then x y is outside the circle boundary.
If fcircle = 0 then x y is on the circle boundary.
Pk = fcircle(xk+1 + yk-1/2)
Where pk is decision parameter and ½ is taken because it is a midpoint value through which it is easy to calculate
through which it is easy to calculate value of yk and yk-1.
Pk = (xk+12 + yk-1/22)
If pk < 0 then midpoint is inside the circle so y is yk.
Otherwise, we will select next y as yk-1 for the condition pk>0
Conclusion:
If pk<0 then yk+1 = yk (plotting points will be xk+1, yk)
Value of next point pk+1 = pk+2 (xk+1) +1
If pk>0 then yk+1 = yk-1 (plotting points will be xk+1, yk-1)
Value of next point pk+1 = pk+2 (xk+1) +1-2(yk+1)
iii) We wish to draw a line from (0, 0) to (5, 3) in device space, show relevant computation
using: a) DDA Line Algorithm b) Bresenham’s Line Algorithm
a) Use the mid-point circle algorithm to draw the circle centred at (0,0) with radius 12. b)
Calculate the required points to plot the following circle using the midpoint circle
algorithm. Radius (r) = 10, Centre = (3, 4) P0=1-r=-9 , Initial Point (x0, y0) = (0,10).
v) a) Given input ellipse parameter rx=8 and ry=6, determine pixel positions along the
ellipse path in the first quadrant using the midpoint ellipse algorithm. b) now draw the
same ellipse with rx = 6 and ry =8
Intial values and increments for the decision parameter calculations are:

2r2 yx = 0 (with increment 2r2 y = 72)


2r2 x y = 2r2 x r y (with increment - 2r2 x = -128)

For region 1, the intial point for the ellipse centered on the origin is (xo, yo) = (0, 6), and the initial decision
parameter value is

p10 = r2y – r2x ry + ¼ r2x = –332


3. Transformations and View Clipping [10 Marks i)
Discuss Different types of Transformations and Write down 4*4 matrices for each of
the following:
a) To translate by the vector (1,2,3)
b) To scale with respect to the origin by the amount (2,4,6)
c) To rotate around the z-axis by 45 degrees (note sin 45 = cos 45 = 1/sqrt(2))
d) To rotate around the x-axis by 45 degrees.
a) Translation:
A translation moves every point by a fixed distance in the same direction. The movement is caused
by the addition or subtraction of a constant from a function.

b) Scale:
Scaling is a transformation that changes the size and/or the shape of the graph of the function. Note
that until now, none of the transformations we discussed could change the size and shape of a
function they only moved the graphical output from one set of points to another set of points.

c) Rotate:
A rotation is a transformation that is performed by “spinning” the object around a fixed point
known as the center of rotation. Although the concept is simple, it has the most advanced
mathematical process of the transformations discussed.
ii) Suppose we have a unit triangle (shown on the left) and we want to transform it into
the triangle on the right. Write a matrix (give all the entries in matrix) that transforms
the triangle in the desired way.
iii) Sequence of transformations can often be simplified. Suppose we have the
following sequence of 2D transformations: R(90) T(0,1) R(90) T(2,0). Assume you
have a unit square (extending from 0 to 1 in x and y) at the origin. Draw out the
intermediate four positions of the square as each transformation is applied

iv) Describe in detail the Cohen-Sutherland clipping algorithm for clipping a line segment

Cohen Sutherland Algorithm is a line clipping algorithm that cuts lines to portions which are within a
rectangular area. It eliminates the lines from a given set of lines and rectangle area of interest (view port)
which belongs outside the area of interest and clip those lines which are partially inside the area of interest.
Example:

Algorithm
The algorithm divides a two-dimensional space into 9 regions (eight outside regions and one inside
region) and then efficiently determines the lines and portions of lines that are visible in the central region
of interest (the viewport).
Following image illustrates the 9 regions:
As you seen each region is denoted by a 4 bit code like 0101 for the bottom right region

Four Bit code is calculated by comparing extreme end point of given line (x,y) by four co-ordinates
x_min, x_max, y_max, y_min which are the coordinates of the area of interest (0000)

Calculate the four bit code as follows:

• Set First Bit if 1 Points lies to left of window (x < x_min)


• Set Second Bit if 1 Points lies to right of window (x > x_max)
• Set Third Bit if 1 Points lies to bottom of window (y < y_min)
• Set Fourth Bit if 1 Points lies to top of window (y > y_max)

The more efficient Cohen-Sutherland Algorithm performs initial tests on a line to determine whether
intersection calculations can be avoided.
Pseudocode
• Step 1 : Assign a region code for two endpoints of given line
• Step 2 : If both endpoints have a region code 0000 then given line is completely inside and we will
keep this line
• Step 3 : If step 2 fails, perform the logical AND operation for both region codes.
• Step 3.1 : If the result is not 0000, then given line is completely outside.
• Step 3.2 : Else line is partially inside.
• Step 3.2.a : Choose an endpoint of the line that is outside the given rectangle.
• Step 3.2.b : Find the intersection point of the rectangular boundary (based on region
code).
• Step 3.2.c : Replace endpoint with the intersection point and update the region code.
• Step 3.2.d : Repeat step 2 until we find a clipped line either trivially accepted or
rejected.
• Step 4 : Repeat step 1 for all lines
What is the limitation of Cohen Sutherland algorithm?

it works only for rectangular clip window

it takes exponential time

it cannot handle parallel lines

it works only for lines with integer length

1. Miscellaneous
i) Describe different type of projections.

The following list explains the different projection types that can be used with the camera. The most
common types are the perspective and orthographic projections. The CAMERA_TYPE should be
the first item in a camera statement. If none is specified, the perspective camera is the default.

You should note that the vista buffer can only be used with the perspective and orthographic camera.

Fisheye projection

This is a spherical projection. The viewing angle is specified by the angle keyword. An angle of 180
degrees creates the "standard" fisheye while an angle of 360 degrees creates a super-fisheye ("I-see-
everything-view"). If you use this projection you should get a circular image. If this isn't the case, i.e.
you get an elliptical image, you should read "Aspect Ratio".
Ultra wide angle projection

This projection is somewhat similar to the fisheye but it projects the image onto a rectangle instead
of a circle. The viewing angle can be specified using the angle keyword.

Omnimax projection

The omnimax projection is a 180 degrees’ fisheye that has a reduced viewing angle in the vertical
direction. In reality this projection is used to make movies that can be viewed in the dome-like
Omnimax theaters. The image will look somewhat elliptical. The angle keyword isn't used with this
projection.

Panoramic projection

This projection is called "cylindrical equirectangular projection". It overcomes the degeneration


problem of the perspective projection if the viewing angle approaches 180 degrees. It uses a type of
cylindrical projection to be able to use viewing angles larger than 180 degrees with a tolerable lateral-
stretching distortion. The angle keyword is used to determine the viewing angle.

Cylindrical projection

Using this projection, the scene is projected onto a cylinder. There are four different types of
cylindrical projections depending on the orientation of the cylinder and the position of the viewpoint.
A float value in the range 1 to 4 must follow the cylinder keyword. The viewing angle and the length
of the up or right vector determine the dimensions of the camera and the visible image. The camera
to use is specified by a number. The types are:

1. vertical cylinder, fixed viewpoint


2. horizontal cylinder, fixed viewpoint
3. vertical cylinder, viewpoint moves along the cylinder's axis
4. horizontal cylinder, viewpoint moves along the cylinder's axis

This has a number of uses. Firstly, it allows an image rendered with the spherical camera to be mapped
on a sphere without distortion (with the fisheye camera, you first have to convert the image from
polar to rectangular coordinates in some image editor). Also, it allows effects such as "environment
mapping", often used for simulating reflections in scanline renderers.

ii) Discuss the following curves:


a) Hermite Curves
A Hermite curve is a spline where every piece is a third degree polynomial defined in Hermite
form: that is, by its values and initial derivatives at the end points of the equivalent domain
interval. Cubic Hermite splines are normally used for interpolation of numeric values defined at
certain dispute values x1,x2,x3, ….. xn,to achieve a smooth continuous function. The data should
have the preferred function value and derivative at each Xk. The Hermite formula is used to every
interval (Xk, Xk+1) individually. The resulting spline become continuous and will have first
derivative.
Cubic polynomial splines are specially used in computer geometric modeling to attain curves that
pass via defined points of the plane in 3D space. In these purposes, each coordinate of the plane
is individually interpolated by a cubic spline function of a divided parameter.

b) Bezier Curves
A Bezier curve is a parametric curve used in computer graphics and related fields. The curves,
which are related to Bernstein polynomials, are named after Pierre Bezier, who used it in the
1960s for designing curves for the bodywork of Renault cars. Other uses include the design of
computer fonts and animation. Bezier curves can be combined to form a Bezier spline, or
generalized to higher dimensions to form Bezier surfaces. The Bezier triangle is a special case of
the latter.

c) B-Spline Curves

In the mathematical subfield of numerical analysis, a B-spline or basis spline is a spline function
that has minimal support with respect to a given degree, smoothness, and domain partition. Any
spline function of given degree can be expressed as a linear combination of B-splines of that
degree. Cardinal B-splines have knots that are equidistant from each other. B-splines can be used
for curve-fitting and numerical differentiation of experimental data.
In computer-aided design and computer graphics, spline functions are constructed as linear
combinations of B-splines with a set of control points.

iii) In Illumination Models, Shading, and Ray Tracing, Define the following:

a) Gouraud Shading
Gouraud shading is a method used in computer graphics to simulate the differing effects of light and
colour across the surface of an object. In practice, Gouraud shading is used to achieve smooth lighting on
low-polygon surfaces without the heavy computational requirements of calculating lighting for each pixel.

b) Visible Surface Ray Tracing


In 3D computer graphics, ray tracing is a rendering technique for generating an image by tracing the path
of light as pixels in an image plane and simulating the effects of its encounters with virtual objects.
The technique is capable of producing a high degree of visual realism, more so than typical scanline
rendering methods, but at a greater computational cost. This makes ray tracing best suited for applications
where taking a relatively long time to render can be tolerated, such as in still computer-generated images,
and film and television visual effects (VFX), but generally more poorly suited to real-time applications
such as video games, where speed is critical in rendering each frame.

iv) Discuss the following animation techniques:


a) Inbetweening
Inbetweening is the process of creating transitional frames between two separate objects in order to
show the appearance of movement and evolution of the first object into the second object. It is a
common technique used in many types of animation. The frames between the key frames (the first and
last frames of the animation) are called “inbetweens” and they help make the illusion of fluid motion.
b) Double buffering
Double buffering is a technique for reducing flicker in animations that at first might seem a little
counter intuitive. The problem stems from the fact that when a new animation frame is rendered, it is
desirable to first clear the old frame. This causes a flicker to occur. The basic idea of double buffering
is to create a virtual screen out of the user's view. At the beginning of this chapter, it was stated that a
graphics device could be a screen, printer, file, or memory area. The virtual screen used as the buffer
is the primary example of using a memory space as a graphics device.

c) Kinematics
Forward kinematics is a method in 3D computer graphics for animating models. The concept of
forward kinematic animation is that the positions of particular parts of the model at a specified time
are calculated from the position and orientation of the object.

You might also like