2. POINTS AND LINES:
A line connects two points. It is a basic element in
graphics.
To draw a line, you need two points between
which youcandraw aline.
In the following three algorithms, we refer the
one point of line as X0,Y0 and the second point of
lineasX1,Y1.
4. Pointsisthefundamentalelementof picturerepresentation.
Two points represent line or edge and 3 or more points a
polygon.
Curvedlinesarerepresentedbytheshort straightlines.
It is the position in the plan defined as either pair or triplets of
numberdependinguponthedimension.
5. LINE-DRAWING ALGORITHMS:
The process of ”turing on” the pixels for a line segment is
called vector generation or line generation,and the
algorithms for them are known as vector generation
algorithmsorlinedrawingalgorithms.
Before discussing specific line drawing algorithms it is
useful to note the general requirements for such
algorithms.
6. The cartesian slope-intercept equation for a straight line
is y=m.x+b
Slopeofthelinem= y2-y1/x2-x1
Interceptbwith b=y1-m.x1
7. The line should appears as a straight line and it
shouldstartandendaccurately.
The line should be displayed with constant
brightness alongit
lengthandorientation.
Thelineshouldbedrawnrapidly
Theserequirementspecifythedesiredcharacteristicsofline:
8.
9. Input: At least one or more inputs must be accept a good
algorithm.
Output:Atleastoneoutputmustproducedanalgorithm.
An algorithm should be precise: The algorithm’s each step
mustwell-define.
Finiteness: Finiteness is require in an algorithm. It signifies
that the algorithm will come to a halt once all of the steps
havebeencomplete.
PropertiesofaLineDrawing Algorithm:
10. Correctness: An algorithm must implemented
correctly.
Uniqueness: The result of an algorithm should be
basedonthe given input, andall stepsof the algorithm
shouldbeclearlyanduniquelydefined.
Effectiveness: An algorithm’s steps must be correct
andefficient.
Easy to understand: Learners must be able to
understand the solution in a more natural way thanks
toanalgorithm.
11. DDA ALGORITHM:
The digital differential analyser(DDA) is a scan-
conversion line algorithm based on calculating
either ∆yor ∆x.
A linear DDA starts by calculating the smaller of dy
or dxforaunitincrementof theother.
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
toplot theline.
14. Sample at unit x intervals(∆x = 1) and compute each successive y
valueas yk+1 =yk +m.
Sample at unit y intervals(∆y = 1) and compute each succeeding x
valueas xk+1 =xk + 1/m.
If this processing is reversed,so that the starting ebdpoint is at
right,then either∆x=-1
If absolute value of the slope is less than 1 and the start endpoint is at
theleft, ∆x=1
15. The digital differential analyser(DDA) is a scan-conversion line algorithm
based oncalculatingeither∆yor ∆x.
A linear DDA starts by calculating the smaller of dy or dx for a unit
incrementof the other.
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 plotthe line.
16. BRESENHAM’S LINE ALGORITHM:
The main task is to find all the intermediate points required
fordrawinglineABonthecomputerscreen of pixels.
In this algorithm, every pixel has integer coordinates. Apart
from that, the Bresenham algorithm works on addition and
subtractionoperations.
This algorithmis usedforscanconvertingaline.
17. It’s a line drawing algorithm that determines the points of
an n-dimensional raster that should be selected in order
to form a close approximation to a straight line between
two points.
Bresenham's algorithm - a fundamental method in
Computer Graphics - is a clever way of approximating a
continuous straight line with discrete pixels, ensuring
that the line appears straight and smooth on a pixel-
based display.
20. Thedifference between two-pixel places served thebasis forthis
straightforward decision:
d_lower -d_upper=2m(xk +1) - 2yk +2b -1
Let’ssubstitute mwith ∆y/∆xwhere ∆xand∆yarethedifferences
between theendpoints:
∆x(d_lower -d_upper)=∆x( (2∆y/∆x)(xk +1)-2yk) +(2b -1)
=2∆y.xk -2∆x.yk +2∆y +∆x(2b -1)
=2∆y.xk -2∆x.yk + c
So, atthekthstep alongaline, adecisionparameterpk isgivenby:
pk=∆x(d_upper-d_lower)
=2∆y.xk -2∆x.yk +c
21. Thevalues ofsuccessive decisionparameters using
incremental integercalculation.Atstep k+1, the decision
parameterisevaluated from as:
pk+1=2∆y.(xk+1) -2∆x.(yk+1) + c
From thepreceding equation:
pk+1 -pk =2∆y.(xk+1 - xk) -2∆x (yk+1 -yk)
But xk+1= xk +1
pk+1 =pk +2∆y -2∆x(yk+1 -yk)
22. Whereyk+1-yk iseither 0or1dependingonthe
signofpk
Theinitialdecisionparameterp0 isevaluated at
(x0,y0)andiswritten asfollows:
p0 =2∆y-∆x
Bresenham Line drawing algorithm is used for scan converting a line. It is an
efficient method because it involves integer addition, subtraction, and
multiplication operations. Because these actions may be completed quickly,
linescanbegenerated quickly.