CG Theory Assignment
CG Theory Assignment
Name: Bakhtawer
BASIS FOR
RASTER SCAN RANDOM SCAN
COMPARISON
Electron beam Swept across the screen and Directed to the portions of the
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?
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.
PPI = 1639/15.36
PPI = 106.7
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:
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
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)
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?
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
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:
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.
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.
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.