Computer Graphics Unit 1 Bca 4th Sem Ccsu
Computer Graphics Unit 1 Bca 4th Sem Ccsu
Introduction:
Today, computers have become important tools that produce pictures economically.
Graphical displays can be used in all areas. Therefore, its extensive usage is not surprising.
Although early applications in science and engineering had to rely on cumbersome and
expensive equipment, current advances in computer technology have made interactive
computer graphics a practical tool. Today, computer graphics are being used in diverse
areas like engineering, science, business, medicine, government, industry, entertainment,
training, education and art. In computers, the term graphics implies almost everything that
is neither text nor sound. These days, almost all computers use some level of graphics, and
computer users expect to control their computers through shortcuts/icons and images. They
no longer depend on typing alone. One thinks of computer graphics as drawing pictures on
computer systems. These can be drawings, photographs, simulations (like java applets), or
movies. On the other hand, they may be images from places one cannot see directly, such
as medical images (DNA structure, etc.) from inside our body. One would like to use
images on computers to not just look more practical, but also to be more practical in terms
of their colour and brightness combinations, the way different materials appear, and the
way objects are lighted.
Computer graphics is mainly used in the process of design, generally for engineering and
architectural systems. But almost all products are now computer designed. Generally
Computer-aided design (CAD) methods are now used to design automobiles, buildings,
watercraft, aircraft, embedded systems, spacecraft, textiles and many other products.
Computer Graphics is the creation of pictures with the help of a computer. The end product of the
computer graphics is a picture it may be a business graph, drawing, and engineering. In computer
graphics, two or three-dimensional pictures can be created that are used for research.
Suppose a shoe manufacturing company want to show the sale of shoes for five years. For this
vast amount of information is to store. So a lot of time and memory will be needed. This method
will be tough to understand by a common man. In this situation graphics is a better alternative.
Graphics tools are charts and graphs. Using graphs, data can be represented in pictorial form. A
picture can be understood easily just with a single look.
Application of Computer Graphics
1. Education and Training: Computer-generated model of the physical, financial and economic
system is often used as educational aids. Model of physical systems, physiological system,
population trends or equipment can help trainees to understand the operation of the system.
For some training applications, particular systems are designed. For example Flight Simulator.
Flight Simulator: It helps in giving training to the pilots of airplanes. These pilots spend much
of their training not in a real aircraft but on the ground at the controls of a Flight Simulator.
Advantages:
1. Fuel Saving
2. Safety
3. Ability to familiarize the training with a large number of the world's airports.
2. Use in Biology: Molecular biologist can display a picture of molecules and gain insight into
their structure with the help of computer graphics.
3. Computer-Generated Maps: Town planners and transportation engineers can use computer-
generated maps which display data useful to them in their planning work.
5. Presentation Graphics: Example of presentation Graphics are bar charts, line graphs, pie
charts and other displays showing relationships between multiple parameters.
6. Computer Art: Computer Graphics are also used in the field of commercial arts. It is used to
generate television and advertising commercial.
7. Entertainment: Computer Graphics are now commonly used in making motion pictures,
music videos and television shows.
8. Printing Technology: Computer Graphics is used for printing technology and textile design.
In non-interactive computer graphics, the picture is produced on the monitor, and the user does
not have any controlled over the image, i.e., the user cannot make any change in the rendered
image. One example of its Titles shown on T.V.
Non-interactive Graphics involves only one-way communication between the computer and the
user, User can see the produced image, and he cannot make any change in the image.
(b) Interactive Computer Graphics: Interactive computer graphics work using the concept of two-
way communication between computer users. The computer will receive signals from the input
device, and the picture is modified accordingly. Picture will be changed quickly when we apply
command. In interactive Computer Graphics user have some controls over the picture, i.e., the user can
make any change in the produced image. One example of it is the ping-pong game.
Interactive Computer Graphics require two-way communication between the computer and the
user. A User can see the image and make any change by sending his command with an input
device.
Advantages:
1. Higher Quality
2. More precise results or products
3. Greater Productivity
4. Lower analysis and design cost
5. Significantly enhances our ability to understand data and to perceive trends.
The modern graphics display is very simple in construction. It consists of three components:
o At a minimum, there is 1 memory bit for each pixel in the raster. This amount of memory
is called a bit plane.
o A 1024 x 1024 element requires 2 20 (210=1024;220=1024 x 1024)sq.raster or 1,048,576
memory bits in a single bit plane.
o ∵ A memory bit has only two states (binary 0 or 1), a single bit plane yields a black and
white (monochrome display).
o As frame buffer is a digital device write raster CRT is an analog device.
2. Resolution: Use to describe the number of pixels that are used on display image.
3. Aspect Ratio: It is the ratio of width to its height. Its measure is unit in length or number of
pixels.
Aspect Ratio =
Representative uses of Computer Graphics:
The computer graphics is one of the most effective and commonly used way to communicate the
processed information to the user. It displays the information in the form of graphics objects such
as pictures, charts, graphs and diagrams instead of simple text.
•The Computer Graphics is rendering (Service) tool for generation of images and manipulation
of images.
•Computer graphics is the technology that deals with designs and pictures on computers.
•Computer graphics is the sub part of Compute Science which studies about manipulating visual
content, Synthesizing digitally.
Computer Graphics made up of 4 Components :-
• Image: an Image is a Combination of pixels, a Visual Representation of Something.
• Models: 3d Representation of Something is Called Model.
• Rendering: Rendering is the process of generating an image from a 2D or 3D model or models
in what collectively could be called a scene file by means of computer programs. Also, the
results of such a model can be called a rendering.
• Animation: Techniques of creating illusive movements using Successive Images is called
Animation.
Representative Uses of Computer Graphics :-
• User interfaces: GUI, etc.
• Business, science and technology: histograms, bar and pie charts, etc.
• Office automation and electronic publishing: text , tables, graphs, hypermedia systems, etc.
• Computer-aided design (CAD): structures of building, automobile bodies, etc.
• Simulation and animation for scientific visualization and entertainment: flight simulation,
games, movies, virtual reality, etc.
• Art and commerce: terminals in public places such as museums, etc.
• Cartography: map making.
a. Output Technology:
Output is the term denoting either an exit or changes which exit a system and which
activate/modify a process. It is an abstract concept, used in the modeling, system(s) design and
system(s) exploitation.
Pictures created and manipulated through the use of computer devices. The term computer
graphics generally pertains to any computer device or program that makes a computer capable of
displaying and manipulating pictures. For example: a laser printer is said to be a computer
graphics device because it allows the computer to output pictures; likewise, a computer display
monitor can display pictures. Computer graphics are used for various applications including
publishing, education, entertainment, and advertising, or wherever pictures are deemed
reasonable or necessary in the creation of a message. They are also used very effectively in
situations where there is a need for computed data to be visualized, such as in statistical charts or
graphs of mathematical data. Most computer graphics can also be drawn by an artist, but the
computer can accomplish much more in a much shorter period of time. One of the major benefits
of computer graphics is that images can be manipulated with relative ease and that a multitude of
visual effects are possible because the images can be played with over and over again until a
desired effect is achieved.
A general purpose computer has four main components: the arithmetic logic unit (ALU), the
control unit, the memory, and the input and output devices (collectively termed I/O). These parts
are interconnected by buses, often made of groups of wires.
Inside each of these parts are thousands to trillions of small electrical circuits which can be
turned off or on by means of an electronic switch. Each circuit represents a bit (binary digit) of
information so that when the circuit is on it represents a "1", and when off it represents a "0" (in
positive logic representation). The circuits are arranged in logic gates so that one or more of the
circuits may control the state of one or more of the other circuits.
The control unit, ALU, registers, and basic I/O (and often other hardware closely linked with
these) are collectively known as a central processing unit (CPU). Early CPUs were composed of
many separate components but since the mid-1970s CPUs have typically been constructed on a
single integrated circuit called a microprocessor.
I/O is the means by which a computer exchanges information with the outside world. Devices
that provide input or output to the computer are called peripherals. On a typical personal
computer, peripherals include input devices like the keyboard and mouse, and output devices
such as the display and printer. Hard disk drives, floppy disk drives and optical disc drives serve
as both input and output devices. Computer networking is another form of I/O.
b. Input Technology:
Advances in computer graphics have transformed how we use computers. Computer graphics
has given us the "mouse" input device, "what-you-see-is-what-you-get" document preparation
systems, the computer-aided design system used to create the Boeing 777, the ability to visualize
molecular dynamics and other scientific phenomena, the animation used in educational software
and the advertising and entertainment industries, and virtual reality systems whose applications
range from architectural prototyping to surgical training to entertainment. Today, every user of a
computer benefits from computer graphics, even in applications such as word processors,
spreadsheets, databases, and project planners. Because of user-friendly graphical user interfaces,
pre-scholars now routinely use computers, a revolution undreamt of even a few years ago.
While everyone is familiar with the mouse, multiple "windows" on computer screens, and
stunningly realistic images of everything from animated logos in television advertisements to
NASA animations of spacecraft flying past Saturn, few people realize that these innovations
were spawned by federally sponsored university research. Without far-sighted support from
agencies such as the Department of Defense Advanced Research Projects Agency and the
National Science Foundation, computer graphics and the multi-billion-dollar industry it makes
possible would have developed much more slowly, and perhaps not predominantly in the U.S.
c. Software Technology:
The aim of this work is to show how the most advanced technology together with spatial
analysis can be usefully employed to investigate historical and archaeological phenomena. In this
note some preliminary results are shown. Two geographical information systems (GIS) were
structured in an integrated way. The first GIS is a vector-like system while the other is a raster-
like one. Moreover, some applications regarding the environmental reconstruction of a part of
the investigated area are proposed. Then the identification and the modeling of archaeological
site maps by means of point pattern analysis are proposed. Finally, an auto-logistic model to
predict archaeological site is presented. This topic is currently under investigation.
It is a process of representing graphics objects a collection of pixels. The graphics objects are
continuous. The pixels used are discrete. Each pixel can have either on or off state.
The circuitry of the video display device of the computer is capable of converting binary values
(0, 1) into a pixel on and pixel off information. 0 is represented by pixel off. 1 is represented
using pixel on. Using this ability graphics computer represent picture having discrete dots.
Any model of graphics can be reproduced with a dense matrix of dots or points. Most human
beings think graphics objects as points, lines, circles, ellipses. For generating graphical object,
many algorithms have been developed.
1. Point
2. Line
3. Sector
4. Arc
5. Ellipse
6. Rectangle
7. Polygon
8. Characters
9. Filled Regions
The process of converting is also called as rasterization. The algorithms implementation varies
from one computer system to another computer system. Some algorithms are implemented using
the software. Some are performed using hardware or firmware. Some are performed using
various combinations of hardware, firmware, and software.
Pixel or Pel:
The term pixel is a short form of the picture element. It is also called a point or dot. It is the
smallest picture unit accepted by display devices. A picture is constructed from hundreds of such
pixels. Pixels are generated using commands. Lines, circle, arcs, characters; curves are drawn
with closely spaced pixels. To display the digit or letter matrix of pixels is used.
The closer the dots or pixels are, the better will be the quality of picture. Closer the dots are,
crisper will be the picture. Picture will not appear jagged and unclear if pixels are closely spaced.
So the quality of the picture is directly proportional to the density of pixels on the screen.
Pixels are also defined as the smallest addressable unit or element of the screen. Each pixel can
be assigned an address as shown in fig:
Different graphics objects can be generated by setting the different intensity of pixels and
different colors of pixels. Each pixel has some co-ordinate value. The coordinate is represented
using row and column.
P (5, 5) used to represent a pixel in the 5th row and the 5th column. Each pixel has some
intensity value which is represented in memory of computer called a frame buffer. Frame
Buffer is also called a refresh buffer. This memory is a storage area for storing pixels values
using which pictures are displayed. It is also called as digital memory. Inside the buffer, image is
stored as a pattern of binary digits either 0 or 1. So there is an array of 0 or 1 used to represent
the picture. In black and white monitors, black pixels are represented using 1's and white pixels
are represented using 0's. In case of systems having one bit per pixel frame buffer is called a
bitmap. In systems with multiple bits per pixel it is called a pixmap.
A straight line may be defined by two endpoints & an equation. In fig the two endpoints are
described by (x1,y1) and (x2,y2). The equation of the line is used to determine the x, y coordinates
of all the points that lie between these two endpoints.
Using the equation of a straight line, y = mx + b where m = & b = the y interrupt, we can find
values of y by incrementing x from x =x 1, to x = x2. By scan-converting these calculated x, y
values, we represent the line as a sequence of pixels.
1. Line should appear Straight: We must appropriate the line by choosing addressable points
close to it. If we choose well, the line will appear straight, if not, we shall produce crossed lines.
The lines must be generated parallel or at 45° to the x and y-axes. Other lines cause a problem: a
line segment through it starts and finishes at addressable points, may happen to pass through no
another addressable points in between.
2. Lines should terminate accurately: Unless lines are plotted accurately, they may terminate
at the wrong place.
3. Lines should have constant density: Line density is proportional to the no. of dots displayed
divided by the length of the line. To maintain constant density, dots should be equally spaced.
4. Line density should be independent of line length and angle: This can be done by
computing an approximating line-length estimate and to use a line-generation algorithm that
keeps line density constant to within the accuracy of this estimate.
It is the simplest form of conversion. First of all scan P 1 and P2 points. P1 has co-ordinates
(x1',y1') and (x2' y2' ).
Example: A line with starting point as (0, 0) and ending point (6, 18) is given. Calculate value of
intermediate points and slope of line.
⟹ ⟹
⟹ ⟹
Let x = 2 y = 3 x 2 y = 6
⟹ ⟹
Let x = 3 y = 3 x 3 y = 9
⟹ ⟹
Let x = 4 y = 3 x 4 y = 12
Let x = 6 ⟹ y = 3 x 6 ⟹ y = 18
Let x = 5 y = 3 x 5 y = 15
Step6: Calculate m =
Step8: Set (x, y) equal to starting point, i.e., lowest point and xendequal to largest value of x
Step9: Check whether the complete line has been drawn if x=xend, stop
Step13: Go to Step9.
DDA Algorithm
DDA stands for Digital Differential Analyzer. It is an incremental method of scan conversion of
line. In this method calculation is performed at each step but by using results of previous steps.
Given-
Starting coordinates = (X0, Y0)
Ending coordinates = (Xn, Yn)
The points generation using DDA Algorithm involves the following steps-
Step-01:
Calculate ΔX, ΔY and M from the given input.
These parameters are calculated as-
ΔX = Xn – X0
ΔY =Yn – Y0
M = ΔY / ΔX
Step-02:
Find the number of steps or points in between the starting and ending coordinates.
if (absolute (ΔX) > absolute (ΔY))
Steps = absolute (ΔX);
else
Steps = absolute (ΔY);
Step-03:
Suppose the current point is (Xp, Yp) and the next point is (Xp+1, Yp+1).
Find the next point by following the below three cases-
Step-04:
Keep repeating Step-03 until the end point is reached or the number of generated new points
(including the starting and ending points) equals to the steps count.
Q. Calculate the points between the starting point (1, 7) and ending point (11, 17).
Solution-
Given-
Starting coordinates = (X0, Y0) = (1, 7)
Ending coordinates = (Xn, Yn) = (11, 17)
Step-01:
1 7 2 8 (2, 8)
3 9 (3, 9)
4 10 (4, 10)
5 11 (5, 11)
6 12 (6, 12)
7 13 (7, 13)
8 14 (8, 14)
9 15 (9, 15)
10 16 (10, 16)
11 17 (11, 17)
Advantage:
3. It allows us to detect the change in the value of x and y ,so plotting of same point twice is not possible.
Disadvantage:
1. It involves floating point additions rounding off is done. Accumulations of round off error cause accumulation of
error.
2. Rounding off operations and floating point operations consumes a lot of time.
3. It is more suitable for generating line using the software. But it is less suited for hardware implementation.
1. #include<graphics.h>
2. #include<conio.h>
3. #include<stdio.h>
4. void main()
5. {
6. intgd = DETECT ,gm, i;
7. float x, y,dx,dy,steps;
8. int x0, x1, y0, y1;
9. initgraph(&gd, &gm, "C:\\TC\\BGI");
10. setbkcolor(WHITE);
11. x0 = 100 , y0 = 200, x1 = 500, y1 = 300;
12. dx = (float)(x1 - x0);
13. dy = (float)(y1 - y0);
14. if(dx>=dy)
15. {
16. steps = dx;
17. }
18. else
19. {
20. steps = dy;
21. }
22. dx = dx/steps;
23. dy = dy/steps;
24. x = x0;
25. y = y0;
26. i = 1;
27. while(i<= steps)
28. {
29. putpixel(x, y, RED);
30. x += dx;
31. y += dy;
32. i=i+1;
33. }
34. getch();
35. closegraph();
36. }
Output:
Symmetrical DDA:
The Digital Differential Analyzer (DDA) generates lines from their differential equations. The equation of a straight line is
The DDA works on the principle that we simultaneously increment x and y by small steps proportional to the first derivatives
of x and y. In this case of a straight line, the first derivatives are constant and are proportional to ∆x and ∆y . Therefore, we
could generate a line by incrementing x and y by ϵ ∆x and ϵ ∆y, where ϵ is some small quantity. There are two ways to
generate points
1. By rounding to the nearest integer after each incremental step, after rounding we display dots at the resultant x and y.
2. An alternative to rounding the use of arithmetic overflow: x and y are kept in registers that have two parts, integer and
fractional. The incrementing values, which are both less than unity, are repeatedly added to the fractional parts and whenever
the results overflows, the corresponding integer part is incremented. The integer parts of the x and y registers are used in
-n n-1 π
plotting the line. In the case of the symmetrical DDA, we choose ε=2 ,where 2 ≤max (|∆x|,|∆y|)<2
A line drawn with the symmetrical DDA is shown in fig:
Bresenham's Algorithm
This method of line drawing is very effective because it includes integer addition, subtraction,
and multiplication. The calculation is very fast in this method that's why the line is drawn very
quickly in this. We'll need the two endpoints in this and then we have to find the decision
parameters. Let assume that (x1,y1) and (x2,y2) are the two points. So, dx = x2-x1 and dy = y2-
y1.
Procedure-
Given-
Starting coordinates = (X0, Y0)
Ending coordinates = (Xn, Yn)
The points generation using Bresenham Line Drawing Algorithm involves the following steps-
Step-01:
Calculate ΔX and ΔY from the given input.
These parameters are calculated as-
ΔX = Xn – X0
ΔY =Yn – Y0
Step-02:
Calculate the decision parameter Pk.
It is calculated as-
Pk = 2ΔY – ΔX
Step-03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Find the next point depending on the value of decision parameter Pk.
Follow the below two cases-
Step-04:
Keep repeating Step-03 until the end point is reached or number of iterations equals to (ΔX-1)
times.
Calculate the points between the starting coordinates (9, 18) and ending coordinates (14, 22).
Solution-
Given-
Starting coordinates = (X0, Y0) = (9, 18)
Ending coordinates = (Xn, Yn) = (14, 22)
Step-01:
Step-03:
As Pk >= 0, so case-02 is satisfied.
Thus,
Pk+1 = Pk + 2ΔY – 2ΔX = 3 + (2 x 4) – (2 x 5) = 1
Xk+1 = Xk + 1 = 9 + 1 = 10
Yk+1 = Yk + 1 = 18 + 1 = 19
Similarly, Step-03 is executed until the end point is reached or number of iterations equals to 4
times.
(Number of iterations = ΔX – 1 = 5 – 1 = 4)
9 18
3 1 10 19
1 -1 11 20
-1 7 12 20
7 5 13 21
5 3 14 22
Advantages
Disadvantages
Given-
Starting coordinates = (X0, Y0)
Ending coordinates = (Xn, Yn)
The points generation using Mid Point Line Drawing Algorithm involves the following steps-
Step-01:
Calculate ΔX and ΔY from the given input.
These parameters are calculated as-
ΔX = Xn – X0
ΔY =Yn – Y0
Step-02:
Step-03:
The decision whether to increment X or Y coordinate depends upon the flowing values of Dinitial.
Follow the below two cases-
Step-04:
Step-01:
Calculate ΔX and ΔY from the given input.
ΔX = Xn – X0 = 30 – 20 = 10
ΔY =Yn – Y0 = 18 – 10 = 8
Step-02:
alculate Dinitial and ΔD as-
Dinitial = 2ΔY – ΔX = 2 x 8 – 10 = 6
ΔD = 2(ΔY – ΔX) = 2 x (8 – 10) = -4
Step-03:
Thus,
Xk+1 = Xk + 1 = 20 + 1 = 21
Yk+1 = Yk + 1 = 10 + 1 = 11
Dnew = Dinitial + ΔD = 6 + (-4) = 2
imilarly, Step-03 is executed until the end point is reached.
20 10
6 2 21 11
2 -2 22 12
-2 14 23 12
14 10 24 13
10 6 25 14
6 2 26 15
2 -2 27 16
-2 14 28 16
14 10 29 17
10 30 18
1. Bresenham’s Circle Drawing Algorithm is a circle drawing algorithm that selects the
nearest pixel position to complete the arc. The unique part of this algorithm is that is uses only
integer arithmetic which makes it, significantly, faster than other algorithms using floating
point arithmetic in classical processors.
As per Eight way symmetry property of circle, circle can be divided into 8 octants each of 45-
degrees.
The Algorithm calculate the location of pixels in the first octant of 45 degrees and extends it to
the other 7 octants. For every pixel (x, y), the algorithm draw a pixel in each of the 8 octants of
the circle as shown below :
N (x+1, y)
S (x+1, y-1)
It is decided by using the decision parameter d as:
Given-
Centre point of Circle = (X0, Y0)
Radius of Circle = R
The points generation using Bresenham Circle Drawing Algorithm involves the following steps-
Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
Y0 = R
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 3 – 2 x R
Step-03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Find the next point of the first octant depending on the value of decision parameter Pk.
Follow the below two cases-
Step-04:
If the given centre point (X0, Y0) is not (0, 0), then do the following and plot the point-
Xplot = Xc + X0
Yplot = Yc + Y0
Step-05:
Keep repeating Step-03 and Step-04 until Xplot = Yplot.
Step-06:
Step-05 generates all the points for one octant.
To find the points for other seven octants, follow the eight symmetry property of circle.
This is depicted by the following figure-
Q. Given the centre point coordinates (0, 0) and radius as 8, generate all the points to form a
circle.
Solution-
Given-
Centre Coordinates of Circle (X0, Y0) = (0, 0)
Radius of Circle = 8
Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
Y0 = R = 8
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 3 – 2 x R
P0 = 3 – 2 x 8
P0 = -13
Step-03:
As Pinitial < 0, so case-01 is satisfied.
Thus,
Xk+1 = Xk + 1 = 0 + 1 = 1
Yk+1 = Yk = 8
Pk+1 = Pk + 4 x Xk+1 + 6 = -13 + (4 x 1) + 6 = -3
Step-04:
This step is not applicable here as the given centre point coordinates is (0, 0).
Step-05:
Step-03 is executed similarly until Xk+1 >= Yk+1 as follows-
Pk Pk+1 (Xk+1, Yk+1)
(0, 8)
-13 -3 (1, 8)
-3 11 (2, 8)
11 5 (3, 7)
5 7 (4, 6)
7 (5, 5)
(0, 8) (5, 5)
(1, 8) (6, 4)
(2, 8) (7, 3)
(3, 7) (8, 2)
(4, 6) (8, 1)
(5, 5) (8, 0)
2. 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 it’s centre.
Procedure-
Given-
Centre point of Circle = (X0, Y0)
Radius of Circle = R
The points generation using Mid Point Circle Drawing Algorithm involves the following steps-
Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
Y0 = R
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 1 – R
Step-03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Find the next point of the first octant depending on the value of decision parameter Pk.
Follow the below two cases-
Step-04:
If the given centre point (X0, Y0) is not (0, 0), then do the following and plot the point-
Xplot = Xc + X0
Yplot = Yc + Y0
Here, (Xc, Yc) denotes the current value of X and Y coordinates.
Step-05:
Keep repeating Step-03 and Step-04 until Xplot >= Yplot.
Step-06:
Step-05 generates all the points for one octant.
To find the points for other seven octants, follow the eight symmetry property of circle.
This is depicted by the following figure-
Q. Given the centre point coordinates (0, 0) and radius as 10, generate all the points to form a
circle.
Solution-
Given-
Centre Coordinates of Circle (X0, Y0) = (0, 0)
Radius of Circle = 10
Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
Y0 = R = 10
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 1 – R
P0 = 1 – 10
P0 = -9
Step-03:
Step-04:
This step is not applicable here as the given centre point coordinates is (0, 0).
Step-05:
Step-03 is executed similarly until Xk+1 >= Yk+1 as follows-
(0, 10)
-9 -6 (1, 10)
-6 -1 (2, 10)
-1 6 (3, 10)
6 -3 (4, 9)
-3 8 (5, 9)
8 5 (6, 8)
Algorithm Terminates
These are all points for Octant-1.
Algorithm calculates all the points of octant-1 and terminates.
Now, the points of octant-2 are obtained using the mirror effect by swapping X and Y
coordinates.
(4, 9) (10, 2)
(5, 9) (10, 1)
(6, 8) (10, 0)
Now, the points for rest of the part are generated by following the signs of other quadrants.
The other points can also be generated by calculating each octant separately.
Here, all the points have been generated with respect to quadrant-1-
Ellipse is defined as the geometric figure which is the set of all points on a plane whose distance
from two fixed points known as the foci remains a constant.
It consists of two axes: major and minor axes where the major axis is the longest diameter and
minor axis is the shortest diameter.
Unlike circle, the ellipse has four-way symmetry property which means that only the quadrants
are symmetric while the octants are not.
The mid-point ellipse drawing algorithm is used to calculate all the perimeter points of an
ellipse. In this algorithm, the mid-point between the two pixels is calculated which helps in
calculating the decision parameter. The value of the decision parameter determines whether the
mid-point lies inside, outside, or on the ellipse boundary and the then position of the mid-point
helps in drawing the ellipse.
This is an incremental method for scan converting an ellipse that is centered at the origin in
standard position i.e., with the major and minor axis parallel to coordinate system axis. It is very
similar to the midpoint circle algorithm. Because of the four-way symmetry property we need to
consider the entire elliptical curve in the first quadrant.
Let's rewrite the ellipse equation and define the function f that can be used to decide if the
midpoint between two candidate pixels is inside or outside the ellipse:
Advantages:
The mid-point ellipse algorithm has simple and easy implementation as it only includes
addition operations.
Disadvantages:
Long questions:
1. Explain the use of computer graphics.
2. What is the basic concept of line drawing? Explain Bresenham's line algorithm to draw a
line between any two end points.
3. What is scan conversion? What steps are required to plot a line whose slope is between 0
to 45 degree using bresenham's method. Indicate which raster locations would be chosen
by bresenham's algorithm when scan-converting a line from screen coordinate (2,3) to
(7,12).
4. Generate the points between the end points of a line viz.(2,2) and (9,6) by using
Bresenham’s line drawing algorithm.
5. Scan convert the line segment with end points (30,20) and (15,10) using DDA line
drawing algorithm.
6. Write short note on DDA.
7. What is mid-point circle algorithm. How does it work?
8. Explain bresenham's circle algorithm in detail.
9. Generate an origin centered circle with radius 2 with eight unique points on the circle.
10. Write down and explain the mid-point circle drawing algorithm. Assume 10cm as the
radius and co-ordinate origin as the centre of the circle.
11. Write down and explain the mid-point ellipse drawing algorithm.