خوارزمية رسم مستقيم هي خوارزمية في الرسوميات الحاسوبية من أجل تقريب قطعة مستقيمة في الأوساط الجغرافية المتقطعة كالشاشات التي تحوي بكسلات أو الطابعات النقطية. بينما في الأوساط المستمرة مثل راسم الإشارة ليس هناك أي حاجة لخوارزمية من أجل رسم مستقيم بسبب استخدام ظواهر فيزيائية لعمل ذلك.
dx = x2 - x1
dy = y2 - y1
for x from x1 to x2 {
y = y1 + (dy) * (x - x1)/(dx)
plot(x, y)
}
في الكود السابق يتم افتراض أن النقاط مرتبة بحيث أن . تعمل هذه الخوارزمية بشكل جيد عندما يكون ولكنها بطيئة جداً على الحاسوب حيث أنها تتطلب عمليات على أرقام ذات فاصلة عائمة. أما إذا كان فإن المستقيم يصبح خشناً جداً وفي حالة النهايات يتم رسم نقطة وحيدة.
This browser is not supported by Wikiwand :( Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience. Please download and use one of the following browsers:
Your input will affect cover photo selection, along with input from other users.
X
Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?
Oh no, there's been an error
Please help us solve this error by emailing us at support@wikiwand.com
Let us know what you've done that caused this error, what browser you're using, and whether you have any special extensions/add-ons installed.
Thank you!