Scan Converting Ellipse Algorithm: by Amjad Khan Khalil Amjad@aup - Edu.pk
Scan Converting Ellipse Algorithm: by Amjad Khan Khalil Amjad@aup - Edu.pk
Algorithm
By
Amjad Khan Khalil
[email protected]
Ellipse
Its is the set of points where the sum of distances of
each point from the focii points remains the same.
Ellipse is an elongated circle therefore an elliptical
curve can be drawn by modifying the circle drawing
procedures to take into an account the different
dimensions of an ellipse along the major and minor
axes.
The mid point algorithm is used for drawing an
ellipse is based on the selection of most favorable
point on the ellipse which depend upon the decision
variables and the value calculated on the mid point.
Mid point Ellipse algorithm
j > i in region 1
j < i in region 2
Con’t
As we know that the ellipse equation is
x2/a2+y2/b2=1
Or we can say that
f(x, y)= b2x2+a2y2-a2b2
Differentiate the above equation w.r.t x we get
a2y=b2x
Which show the boundary of region-I and
region-II
Con’t
If a2y> b2x then it means that we are
in region-I
dnew=dold-2a2(yp-1)+b2(3+2xp)
Region-I Case(II)
If dold < 0 then it means that the mid point
is inside the ellipse and the ellipse passes
near the upper pixel and thus upper pixel is
selected and the decision parameters for the
next pixel position is as under
M(xp+2, yp-1/2)
Thus
dnew= a2(yp-1/2)2+b2(xp+2)2-a2b2 c
Con’t
Thus subtracting eq(A) from eq(C) we
get the following equation
dnew=dold+b2(2xp+3)
Region-I Case-III
If dold=0 then the ellipse passes
through the mid point and thus is at
equal distance from both of the pixels
and we can select any pixel in this case.
If you select the lower pixel then use
case-I.
If you select the upper pixel then use
case-II
Region-II
In region-II the geometry of the line is more
vertical as compare to region-I and thus
using the mid point algorithm we have to
choose mid point between left and right
pixels
If P(xp,yp) is the starting pixel then the mid
point coordinates will be
M(xp+1/2, yp-1)
Thus the ellipse equation becomes
dold= a2(yp-1)2+b2(xp+1/2)2-a2b2 1
Region-II Case-I
If dold<0 it means that the point is
inside the ellipse so the ellipse passes
near the right pixel and thus right pixel is
selected and the decision variable for
selecting next pixel position will be
M(xp+3/2, yp-2)
thus
dnew= a2(yp-2)2+b2(xp+3/2)2-a2b2 2
Con’t
Subtracting eq(1) from eq(2) we get
dnew=dold+a2(3-2yp)+2b2(1+xp)
So if the right pixel R is selected then
the next point position will be computed
using the above equation
Region-II Case-II
If dold>0 then the point is outside the
ellipse and the ellipse passes near the
left pixel so the decision parameters for
next pixel position will be
M(xp+1/2, yp-2)
Thus
dnew= a2(yp-2)2+b2(xp+1/2)2-a2b2 3
Con’t
By subtracting eq(1) from eq(3) we get
dnew=dold+a2(3-2yp)
So if the left pixel is selected then the
above equation is used to compute the
next pixel position.
Region-II Case-III
If dold=0 then the ellipse passes
through the mid point and you can
select any of the pixels
If you select the R pixel then use case-I
If you select the L pixel then use
case-II
Examples
Find out the next pixel position using scan
converting ellipse algorithm if the starting
pixel is P(3,5) and value of major axis is 4
and minor axis is 5.
Find out the coordinates of next pixel using
Bresenham’s Mid point Ellipse algorithm if the
starting pixel is P(5,7) and value of major
axis is 5 and minor axis 6.
Examples
Using Scan converting Ellipse algorithm find
out the region and position of next two pixels
if the starting pixel is P(4,6) and value of
major axis is 5 and minor axis is 6
Find out the position of next two pixels using
Bresenham’s Mid point Ellipse algorithm if the
starting pixel is P(2,6) and value of major
axis is 3 and minor is 7.
Examples
Find out the position of next two pixels
using Bresenham’s Mid point Ellipse
algorithm if the starting pixel is P(2,5) and
value of major axis is 4 and minor is 7.
Find out the position of next two pixels
using Bresenham’s Mid point Ellipse
algorithm if the starting pixel is P(5,3) and
value of major axis is 6 and minor is 7.