Trang 7 Problems■ It seems to work okay for lines with a slope of 1 or less■ Doesn’t work well for lines with slope greater than 1■ Lines become more discontinuous in appearance■ We must
Lesson Basic entity algorithms Trinh Thanh Trung School of ICT, HUST Content Line representation DDA algorithm Bresenham algorithm Mid-point algorithm Circle & ellipse representation Character representation Rasterization: Background ■ Converting a continuous object in the world into a discrete object in the computer ■ We need to lit the pixels instead of drawing a continuous line Line representation Line drawing P(x2 , y2) ■ Line representation u y = k x + b P(x1, y1) with m k = (y2-y1)/( x2-x1) or 𝑦 − 𝑦1 = 𝑦2 − 𝑦1 𝑥 − 𝑥1 𝑥2 − 𝑥1 (explicit form) Line drawing ■ From linear algebra y = k x + b ■ Simple approach: increment x calculate y cast y to an integer draw (x, (int)y) PROBLEM? Problems ■ It seems to work okay for lines with a slope of or less ■ Doesn’t work well for lines with slope greater than ■ Lines become more discontinuous in appearance ■ We must add more than pixel per column to make it work DDA algorithm ■ DDA = Digital Differential Analyser ■ Treat line as parametric equation in t □ Start point (x1, y1) □ End point (x2, y2) ■ From linear algebra y = k x + b □ When 0