The document describes the midpoint ellipse algorithm. It begins with properties of ellipses and the standard ellipse equation. It then explains the midpoint ellipse algorithm, which samples points along an ellipse using different directions in different regions to approximate the elliptical path. Key steps include initializing decision parameters, testing the parameters to determine the next point, and calculating new parameters at each step. Pixel positions are determined and can be plotted.
APEX INSTITUTE was conceptualized in May 2008, keeping in view the dreams of young students by the vision & toil of Er. Shahid Iqbal. We had a very humble beginning as an institute for IIT-JEE / Medical, with a vision to provide an ideal launch pad for serious JEE students . We actually started to make a difference in the way students think and approach problems. We started to develop ways to enhance students IQ. We started to leave an indelible mark on the students who have undergone APEX training. That is why APEX INSTITUTE is very well known of its quality of education
Edhole School provides best Information about Schools in India, Delhi, Noida, Gurgaon. Here you will get about the school, contact, career, etc. Edhole Provides best study material for school students."
APEX INSTITUTE was conceptualized in May 2008, keeping in view the dreams of young students by the vision & toil of Er. Shahid Iqbal. We had a very humble beginning as an institute for IIT-JEE / Medical, with a vision to provide an ideal launch pad for serious JEE students . We actually started to make a difference in the way students think and approach problems. We started to develop ways to enhance students IQ. We started to leave an indelible mark on the students who have undergone APEX training. That is why APEX INSTITUTE is very well known of its quality of education
Edhole School provides best Information about Schools in India, Delhi, Noida, Gurgaon. Here you will get about the school, contact, career, etc. Edhole Provides best study material for school students."
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
2. Lecture outline
n Ellipse-generating algorithm
n Properties of ellipse
n Midpoint ellipse algorithm
2
3. Ellipse Generating Algorithm
n Ellipse – an elongated circle.
n A modified circle whose radius varies from a
maximum value in one direction to a minimum value
in the perpendicular direction.
n A precise definition in terms of
distance from any point on the
d1
ellipse to two fixed position, F1 P=(x,y)
d2
called the foci of the ellipse. F2
n The sum of these two distances
is the same value for all points
on the ellipse. 3
4. Ellipse Generating Algorithm
n If the distance of the two focus positions from any
point P=(x, y) on the ellipse are labeled d1 and d2,
the general equation of an ellipse:
d1 + d2 = constant
n Expressing distance d1 and d2 in terms of the focal
coordinates F1=(x1, y1) and F2=(x2, y2), we have
(x - x1 )2 + ( y - y1 )2 + (x - x2 )2 + ( y - y2 )2 = constant
4
5. Ellipse Generating Algorithm
However, we will only consider ‘standard’ ellipse:
2 2
ry
æ x - xc ö æ y - yc ö
yc
ç
ç r ÷ +ç
÷ ç r
÷ =1
rx
÷
è x ø è y ø
xc
5
6. Symmetry
n An ellipse only has a 4-
way symmetry.
(x,y)
(-x,y) ry
rx
(x,-y)
(-x,-y)
6
7. Equation of an ellipse
n Consider an ellipse centered at the origin,
(xc,yc)=(0,0): 2 2
æxö æyö
ç ÷ + ç ÷ =1
çr ÷ çr ÷
è xø è yø
f e ( x, y ) = ry x + rx y - rx ry
2 2 2 2
Ellipse function 2 2
…and its properties:
fellipse(x,y) < 0 if (x,y) is inside the ellipse
fellipse(x,y) = 0 if (x,y) is on the ellipse
fellipse(x,y) > 0 if (x,y) is outside the ellipse
7
8. Midpoint Ellipse Algorithm
n Ellipse is different from circle.
n Similar approach with circle,
different in sampling direction. Slope =
-1
n Region 1: ry
n Sampling is at x direction
n Choose between (xk+1, yk), or rx
(xk+1, yk-1) Region 1
n Move out if 2r2yx >= 2r2xy Region 2
n Region 2:
n Sampling is at y direction
n Choose between (xk, yk-1), or
(xk+1, yk-1) 8
9. Decision parameters
Region 1: Region 2:
p1k = f e ( xk + 1, yk - 1 2 ) p2k = fe ( xk + 12 , yk -1)
p1k < 0: p2k <= 0:
n midpoint is inside • midpoint is inside/on
n choose pixel (xk+1, yk) • choose pixel (xk+1, yk-1)
p1k >= 0: p2k > 0:
n midpoint is outside/on • midpoint is outside
n choose pixel (xk+1, yk-1) • choose pixel (xk, yk-1)
9
10. Midpoint Ellipse Algorithm
1. Input rx, ry and ellipse center (xc, yc). Obtain the first point on an
ellipse centered on the origin (x0, y0) = (0, ry).
2. Calculate initial value for decision parameter in region 1 as:
2 2 2
p1 0 = r y - rx r y + 1
4 rx
3. At each xk in region 1, starting from k = 0, test p1k :
2 2
If p1k < 0, next point (xk+1, yk) and p1k +1 = p1k + 2 ry xk +1 + ry
2 2 2
else, next point (xk+1, yk-1) and p1k +1 = p1k + 2 ry xk +1 - 2 rx y k +1 + ry
with 2ry2xk+1 = 2ry2xk + 2ry2, 2rx2yk+1 = 2rx2yk – 2rx2
and repeat step 1 to 3 until 2ry2x ³ 2rx2y 10
11. Midpoint Ellipse Algorithm
4. Initial value for decision parameter in region 2:
p 2 0 = ry
2
(x 0 + 1 )2 + rx 2 ( y 0 - 1 )2 - rx 2 r y 2
2
where (x0, y0) is the last position calculate in region 1
5. At each yk in region 2, starting from k = 0, test p2k:
2 2
If p2k > 0, next point is (xk, yk-1) and p 2 k +1 = p 2 k - 2rx y k +1 + rx
2 2 2
else, next point is (xk+1, yk-1) and p 2 k +1 = p 2 k + 2ry xk +1 - 2rx yk +1 + rx
continue until y=0
11
12. Midpoint Ellipse Algorithm
6. For both region determine symmetry points in the other 3
quadrants
7. Move each calculated pixel position (x,y) onto the elliptical path
centered on (xc,yc) and plot the coordinate values
x=x + xc, y =y + yc
12
13. Try this out!
Given input ellipse k p1k (xk+1,yk+1) 2ry2 xk+1 2 rx2yk+1
parameter rx=8 and ry=6, 0 -332 (1,6) 72 768
determine pixel positions 1
along the ellipse path in 2
the first quadrant using 3
the midpoint ellipse 4
algorithm 5
6
2ry2x = ?
k p2k (xk+1,yk+1) 2rv2 xk+1 2 rx2yk+1
2rx2y = 2rx2ry = ?
0
p10 = ?
1
2
13