KEMBAR78
Project Work of Multimedia | PDF | Graphics | Computer Graphics
0% found this document useful (0 votes)
9 views9 pages

Project Work of Multimedia

The document discusses computer graphics, defining it as a field that manipulates visual content and detailing its applications in art, education, entertainment, and more. It also differentiates between raster scan and random scan displays, explains algorithms for drawing circles and lines, and covers 3D transformations like perspective projection, reflection, and rotation. Additionally, it addresses hidden surface removal techniques, emphasizing their importance in rendering realistic images.

Uploaded by

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

Project Work of Multimedia

The document discusses computer graphics, defining it as a field that manipulates visual content and detailing its applications in art, education, entertainment, and more. It also differentiates between raster scan and random scan displays, explains algorithms for drawing circles and lines, and covers 3D transformations like perspective projection, reflection, and rotation. Additionally, it addresses hidden surface removal techniques, emphasizing their importance in rendering realistic images.

Uploaded by

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

Project work of Rajan Sir

Subject: Graphics Designing


Submitted by: Santosh Aryal
Date: 2081-12-12

1. a. Define computer graphics and discuss its applications in different fields.


Ans: Computer graphics is the part of computer science that studies methods for
manipulating visual content although computer graphics deals with 3D graphics, 2D
graphics, and image processing. It also deals with the creation, manipulation, and
storage of different types of images and objects.
There are some of the applications of computer graphics are described below:
 Computer Art: Using computer graphics, we can create fine and commercial art
which includes animation packages, and paint packages. These packages provide
facilities for designing object shapes and specifying object motion. Cartoon
drawings, paintings, and logo designs can also be done.

 Computer-Aided automobiles Drawing: Designing buildings, automobiles, and


aircraft is done with the help of computer-aided drawing, this helps in providing
minute details to the drawing and producing more accurate and sharp drawings
with better specifications.

 Presentation Graphics: For the preparation of reports or summarizing the financial,


statistical, mathematical, scientific, and economic data for research reports, and
managerial reports, moreover creation of bar graphs, pie charts, and time charts,
can be done using the tools present in computer graphics.

 Entertainment: Computer graphics find a major part of its utility in the movie
industry and game industry. Used for creating motion pictures, music videos,
television shows, and cartoon animation films. In the game industry where focus
and interactivity are the key players, computer graphics help in efficiently
providing such features.

 Education: Computer-generated models are extremely useful for teaching huge


number of concepts and fundamentals in an easy-to-understand and learn manner.
Using computer graphics many educational models can be created through which
more interest can be generated among the students regarding the subject.

 Training: Specialized systems for training like simulators can be used for training
the candidates in a way that can be grasped in a short span of time with better
understanding. The creation of training modules using computer graphics is simple
and very useful.
b. Differentiate between raster scan and random scan display.
Ans: The key difference between random scan and raster scan are mentioned below:
Difference between Random Scan and Raster Scan
Base of Difference Random Scan Raster Scan
Resolution The resolution of random While the resolution of raster
scan is higher than raster scan is lesser or lower than
scan. random scan.
Cost It is costlier than raster scan While the cost of raster scan
because it requires more is lesser than random scan.
sophisticated hardware to
control the electron beam
directly
Modification In random scan, any While in raster scan, any
alteration is easy in alteration is not so easy .
comparison of raster scan.
Interlacing In random scan, interlacing While in raster scan,
is not used. interlacing is used.
Line Drawings In random scan, While in which, for image or
mathematical function is picture rendering, raster scan
used for image or picture uses pixels. It is suitable for
rendering. It is suitable for creating realistic scenes.
applications requiring
polygon drawings.
Motion of Electron Electron Beam is directed to Electron Beam is directed
Beam only that part of screen from top to bottom and one
where picture is required to row at a time on screen. It is
be drawn, one line at a time. directed to whole screen.
Picture Definition It stores picture definition It stores picture definition as a
as a set of line commands in set of intensity values of the
the Refresh buffer. pixels in the frame buffer.
Refresh Rate Refresh rate depends on the Refresh rate is 60 to 80
number of lines to be frames per second and is
displayed i.e. 30 to 60 times independent of picture
per second. complexity.
Solid Pattern In random scan, Solid In raster scan, Solid Pattern is
Pattern is tough to fill. easy to fill.
Example Pen Plotter TV Sets

2. Using the midpoint circle algorithm, plot a circle with a radius of 10 centered at
the origin.
Ans: Mid-Point Circle Drawing Algorithm
The mid-point circle drawing algorithm is an algorithm used to determine the points
needed for rasterizing a circle.
We use the mid-point algorithm to calculate all the perimeter points of the circle in
the first octant and then print them along with their mirror points in the other octants.
This will work because a circle is symmetric about its centre.
The algorithm is very similar to the. Here, only the boundary condition is different.
For any given pixel (x, y), the next pixel to be plotted is either (x, y+1) or (x-1, y+1).
This can be decided by following the steps below.

1. Find the mid-point p of the two possible pixels i.e (x-0.5, y+1)
2. If p lies inside or on the circle perimeter, we plot the pixel (x, y+1), otherwise if it’s
outside we plot the pixel (x-1, y+1)
Boundary Condition : Whether the mid-point lies inside or outside the circle can be
decided by using the formula:-

Given a circle centered at (0,0) and radius r and a point p(x,y)


F(p) = x2 + y2 – r2
if F(p)<0, the point is inside the circle
F(p)=0, the point is on the perimeter
F(p)>0, the point is outside the circle
In our program, we denote F(p) with P. The value of P is calculated at the mid-point of
the two contending pixels i.e. (x-0.5, y+1). Each pixel is described with a subscript k.

Pk = (Xk — 0.5)2 + (yk + 1)2 – r2


Now,
xk+1 = xk or xk-1 , yk+1= yk +1
? Pk+1 = (xk+1 – 0.5)2 + (yk+1 +1)2 – r2
= (xk+1 – 0.5)2 + [(yk +1) + 1]2 – r2
= (xk+1 – 0.5)2 + (yk +1)2 + 2(yk + 1) + 1 – r2
= (xk+1 – 0.5)2 + [ – (xk – 0.5)2 +(xk – 0.5)2 ] + (yk + 1)2 – r2 + 2(yk + 1) + 1
= Pk + (xk+1 – 0.5)2 – (xk – 0.5)2 + 2(yk + 1) + 1
= Pk + (x2k+1 – x2k) – (xk+1 – xk) + 2(yk + 1) + 1
= Pk + 2(yk +1) + 1, when Pk <=0 i.e the midpoint is inside the circle
(xk+1 = xk)
Pk + 2(yk +1) – 2(xk – 1) + 1, when Pk>0 I.e the mid point is outside the circle(xk+1 = xk-
1)

The first point to be plotted is (r, 0) on the x-axis. The initial value of P is calculated as
follows:-

P1 = (r – 0.5)2 + (0+1)2 – r2
= 1.25 – r
= 1 -r (When rounded off)

Examples:

Input : Centre -> (0, 0), Radius -> 3


Output : (3, 0) (3, 0) (0, 3) (0, 3)
(3, 1) (-3, 1) (3, -1) (-3, -1)
(1, 3) (-1, 3) (1, -3) (-1, -3)
(2, 2) (-2, 2) (2, -2) (-2, -2)
Input : Centre -> (4, 4), Radius -> 2
Output : (6, 4) (6, 4) (4, 6) (4, 6)
(6, 5) (2, 5) (6, 3) (2, 3)
(5, 6) (3, 6) (5, 2) (3, 2)

3. Derive the DDA line drawing algorithm for slopes m<1 and m>1.
Ans: DDA Line generation Algorithm in Computer Graphics
Introduction :
DDA (Digital Differential Analyzer) is a line drawing algorithm used in computer
graphics to generate a line segment between two specified endpoints. It is a simple and
efficient algorithm that works by using the incremental difference between the x-
coordinates and y-coordinates of the two endpoints to plot the line.
The steps involved in DDA line generation algorithm are:
1. Input the two endpoints of the line segment, (x1,y1) and (x2,y2).
2. Calculate the difference between the x-coordinates and y-coordinates of the endpoints
as dx and dy respectively.
3. Calculate the slope of the line as m = dy/dx.
4. Set the initial point of the line as (x1,y1).
5. Loop through the x-coordinates of the line, incrementing by one each time, and
calculate the corresponding y-coordinate using the equation y = y1 + m(x – x1).
6. Plot the pixel at the calculated (x,y) coordinate.
7. Repeat steps 5 and 6 until the endpoint (x2,y2) is reached.
DDA algorithm is relatively easy to implement and is computationally efficient, making
it suitable for real-time applications. However, it has some limitations, such as the
inability to handle vertical lines and the need for floating-point arithmetic, which can be
slow on some systems. Nonetheless, it remains a popular choice for generating lines in
computer graphics.
In any 2-Dimensional plane, if we connect two points (x0, y0) and (x1, y1), we get a
line segment. But in the case of computer graphics, we can not directly join any two
coordinate points, for that, we should calculate intermediate points’ coordinates and put
a pixel for each intermediate point, of the desired color with the help of functions like ,
where (x,y) is our co-ordinate and K denotes some color.
Examples:
Input: For line segment between (2, 2) and (6, 6) :
Output: we need (3, 3) (4, 4) and (5, 5) as our intermediate points.
Input: For line segment between (0, 2) and (0, 6) :
Output: we need (0, 3) (0, 4) and (0, 5) as our intermediate points.
For using graphics functions, our system output screen is treated as a coordinate system
where the coordinate of the top-left corner is (0, 0) and as we move down our y-ordinate
increases, and as we move right our x-ordinate increases for any point (x, y). Now, for
generating any line segment we need intermediate points and for calculating them we
can use a basic algorithm called line generating algorithm.

DDA Algorithm:
Consider one point of the line as (X0, Y0) and the second point of the line as (X1, Y1).
// calculate dx , dy
dx = X1 – X0;
dy = Y1 – Y0;
// Depending upon absolute value of dx & dy
// choose number of steps to put pixel as
// steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy)
steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
// calculate increment in x & y for each steps
Xinc = dx / (float) steps;
Yinc = dy / (float) steps;
// Put pixel for each step
X = X0;
Y = Y0;
for (int i = 0; i <= steps; i++)
{
putpixel (round(X),round(Y),WHITE);
X += Xinc;
Y += Yinc;
}

4. What is perspective projection? Explain 3D reflection and rotation with examples.


Ans: Understanding 3D transformations like perspective projection, reflection, and
rotation is fundamental in computer graphics.
1. Perspective Projection:
 Concept:
o Perspective projection simulates how our eyes or a camera sees the world.
Objects farther away appear smaller, and parallel lines converge at a vanishing
point. This creates a sense of depth and realism.
o It's a crucial technique for rendering 3D scenes onto a 2D screen.
 How it Works:
o Unlike parallel projection (where parallel lines remain parallel), perspective
projection involves projecting 3D points onto a 2D plane from a "center of
projection" or "camera position."
o This projection process involves dividing the x and y coordinates of a 3D point
by its z-coordinate (distance from the viewer), causing distant objects to shrink.
o key terms to understand are:
 Field of View (FOV): This determines how much of the scene is visible.
 Vanishing Point: The point where parallel lines appear to converge.
 Frustum: The 3D volume that represents the visible area of the camera.

 Example:
o Think of a long straight road. The road's edges appear to converge at a point in
the distance (the vanishing point).8 This is perspective projection in action. In
3D computer graphics, this effect is mathematically modeled to give the illusion
of depth.

2. 3D Reflection:
 Concept:
o 3D reflection creates a mirror image of an object across a plane.
o This plane is often one of the coordinate planes (xy, xz, or yz).
 How it Works:
o To reflect a point across a plane, you change the sign of the coordinate
corresponding to the axis perpendicular to that plane.
 Reflection across the xy-plane: negate the z-coordinate.
 Reflection across the xz-plane: negate the y-coordinate.
 Reflection across the yz-plane: negate the x-coordinate.
 Example:
o Imagine a 3D cube. To reflect it across the xy-plane (as if it's sitting on a mirror
on the floor), you would invert the z-coordinate of each vertex of the cube. So,
if a vertex was at (1, 2, 3), its reflected position would be (1, 2, -3).

3. 3D Rotation:
 Concept:
o 3D rotation turns an object around an axis in 3D space.
o Common rotation axes are the x, y, and z-axes.
 How it Works:
o Rotation is typically performed using rotation matrices. These matrices
transform the coordinates of points to their rotated positions.
o The rotation matrices vary depending on the axis of rotation and the rotation
angle.
 Example:
o Consider rotating a 3D sphere around the z-axis. If you rotate it by 90 degrees,
the sphere's position in the x-y plane changes, but its z-coordinate remains the
same. In computer graphics, this is done by multiplying each of the spheres
verticies by a rotation matrix that is designed to rotate those points around the Z
axis.

5. What are the different hidden surface removal techniques? Explain any two in
detail.
Ans: In 3D computer graphics, hidden surface removal (also known as visible surface
determination) is crucial for rendering realistic images.
It's the process of determining which surfaces and parts of surfaces are visible from a
particular viewpoint, and then eliminating those that are hidden behind other surfaces.
Here's an overview of common techniques, with a detailed look at two of them:
Common Hidden Surface Removal Techniques:
 Z-buffering (Depth buffering):
o This is one of the most widely used techniques.
o It works in image space.
o It uses a depth buffer (z-buffer) to store the depth (z-coordinate) of each pixel.
o As each polygon is rendered, the depth of each of its pixels is compared to the
value in the z-buffer.
o If the new pixel is closer to the viewer than the existing one, its color and depth
are stored in the frame buffer and z-buffer, respectively.
 Painter's Algorithm:
o This is an older technique.
o It sorts all polygons in the scene by their distance from the viewer.
o It then draws the polygons in back-to-front order, so that closer polygons
overwrite farther ones.
o This simulates the way a painter paints a canvas, with background layers being
painted first.

Detailed Explanation of Two Techniques:


1. Z-buffering:
o How it works:
 A depth buffer (z-buffer) is created, with the same dimensions as the
frame buffer.
 Initially, all z-buffer values are set to a very large value (representing
infinity).
 For each pixel of each polygon, the z-coordinate (depth) is calculated.
 This z-coordinate is compared to the corresponding value in the z-buffer.
 If the calculated z-coordinate is less than the z-buffer value, it means the
new pixel is closer to the viewer.
 In this case, the pixel's color is written to the frame buffer, and its z-
coordinate is written to the z-buffer.
 If the calculated z-coordinate is greater than or equal to the z-buffer
value, the pixel is hidden, and nothing is changed.
o Advantages:
 Simple to implement.
 Handles complex scenes with overlapping polygons.
 Polygons can be rendered in any order.
o Disadvantages:
 Requires extra memory for the z-buffer.
 Can have precision issues with very large scenes.

2. Painter's Algorithm:
o How it works:
 All polygons in the scene are sorted by their distance from the viewer.
 The polygons are then drawn in order, from farthest to closest.
 This ensures that closer polygons overwrite farther ones, effectively
hiding them.
o Advantages:
 Relatively simple to understand.
o Disadvantages:
 Sorting polygons can be computationally expensive.
 Can have problems with intersecting or overlapping polygons, requiring
further complex sorting or polygon subdivision.
 Does not always produce correct results.

You might also like