انت هنا الان : شبكة جامعة بابل > موقع الكلية > نظام التعليم الالكتروني > مشاهدة المحاضرة

Ellipse Algorithm

Share |
الكلية كلية العلوم للبنات     القسم قسم الحاسبات     المرحلة 3
أستاذ المادة ايلاف علي عبود       04/01/2017 10:22:43
Ellipse Algorithm:
Ellipse is define by center (x1, y1) , first radius (r1) and second radius (r2). To draw ellipse we must:
1. Find initial point:
x = x1 + r1
y = y1
2. Find the increment value:
x = x1+ r1 * cos (?) …………………..(1)
y = y1+ r2 * sin (?)
by find the differential of equations (1)
dx = -r1 * sin (?) *d(?) ….……………(2)
dy = r2 * cos (?) * d(?)
and from equation (1)
cos (?) = ( x - x1) / r1 ……...…………..(3)
sin (?) = ( y – y1) / r2
substitute equation (3) in (2)
dx = -r1 * ( y – y1) / r2*d(?) ? dx = -r1/r2 * ( y – y1) *d(?)
dy = r2 * ( x - x1) / r1 * d(?) ? dy = r2 /r1 * ( x - x1) * d(?)
where d(?) = 1 / max (r1, r2)
3. The iterations ( number of points) are depend on angle rotation from 0 to 360.
Ellipse Algorithm: center (x1,y1) , first radius (r1), second radius (r2)
Begin
x = x1+ r1
y = y1
theta = 0
dtheta = 1 / max (r1 , r2 )
while theta < 360
SetPixel ( x , y , color )
x = x – (r1 / r2) * (y – y1) * dtheta
y = y – (r2 / r1) * (y – y1) * dtheta
theta = theta + dtheta
end
Arc Algorithm
Arc is define by center (x1, y1) , radius (r), start angle (?) and endangle (?). To draw Arc we must:
1. Find initial point:
x = x1 + r * cos(?)…………………….(1)
y = y1 + r * sin (?)
2. Find the incremental value by find the differential of equations (1) :
dx = -r * sin (?) *d(?) ….……………(2)
dy = r * cos (?) * d(?)
and from equation (1)
cos (?) = ( x - x1) / r ……...…………..(3)
sin (?) = ( y – y1) / r
substitute equation (3) in (2)
dx = - ( y – y1) *d(?) ? dx = ( y1 – y) *d(?)
dy = ( x - x1) * d(?)
where d(?) = 1 / r
3. The iterations ( number of points) are begin from startange(?) to endangle(?).
Arc Algorithm: center (x1 , y1) , radius (r),startangle(?), endangle(?)
Begin
? = startangle * 3.14 / 180
? = endangle * 3.14 / 180
dtheta= 1 / r
x = x1 + r * cos (?)
y = y1 + r * sin (?)
SetPixel(x ,y , color)
While ? < ?
x = x +( y1 – y) *d(?)
y = y +( x - x1) * d(?)
SetPixel(x ,y , color)
? = ? + d(?)
Endwhile
End


المادة المعروضة اعلاه هي مدخل الى المحاضرة المرفوعة بواسطة استاذ(ة) المادة . وقد تبدو لك غير متكاملة . حيث يضع استاذ المادة في بعض الاحيان فقط الجزء الاول من المحاضرة من اجل الاطلاع على ما ستقوم بتحميله لاحقا . في نظام التعليم الالكتروني نوفر هذه الخدمة لكي نبقيك على اطلاع حول محتوى الملف الذي ستقوم بتحميله .
الرجوع الى لوحة التحكم