Page 40 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 40

Lab on Computer Graphics                                         Avinash Bhagat, Lovely Professional University



                   Notes                       Unit 3: Implementing Line Algorithm



                                   CONTENTS

                                   Objectives
                                   Introduction
                                   3.1   Concept of Implementing Line Algorithm
                                   3.2   Concept of Bresenham’s Algorithm
                                       3.2.1   Bresenham’s Algorithm
                                       3.2.2   The Integer Bresenham’s Algorithm
                                       3.2.3   Bresenham’s Algorithm for Lines with Arbitrary Endpoints
                                       3.2.4   Specifying the Driving Axis

                                       3.2.5   C Code Line Drawing Algorithm
                                   3.3   DDA Line Algorithm
                                       3.3.1   Line DDA Algorithm
                                       3.3.2   C Code DDA Line Algorithm
                                   3.4  Summary
                                   3.5  Keywords
                                   3.6   Review Questions

                                   3.7   Further Readings
                                 Objectives


                                 After studying this unit, you will be able to:
                                    •  Discuss the concept of implementing line algorithm
                                    •  Explain the concept of Bresenham’s algorithm

                                    •  Define the DDA line algorithm

                                 Introduction

                                 Line drawing is our first endeavor into the area of scan conversion. The need for scan conversion,
                                 techniques is a direct result of scanning nature of raster displays (thus the names). Vector displays
                                 are mainly well suited for the display of lines. All that is needed on a vector display to generate
                                 a line is to supply the appropriate control voltages to the x and y deflection circuitry, and the
                                 electron beam would traverse the line illuminating the desired segment. The only inaccuracies
                                 in the lines drawn a vector display resulted from various non-line arties, such as quantization
                                 and amplifier saturation, and the various noise sources in the display circuitry. When raster
                                 displays came along the process of drawing lines became more difficult. Luckily, raster display
                                 pioneers could benefit from previous work done in the area of digital plotter algorithms. A
                                 pen-plotter is a hardcopy device used primarily to display engineering line drawings. Digital
                                 plotters, like raster displays, are discretely addressable devices, where position of the pen on a
                                 plotter is controlled by special motors called stepper motors that are connected to mechanical
                                 linkages that translate the motor’s rotation into a linear translation. Stepper motors can precisely
                                 turn a fraction of a rotation (for example 2 degrees) when the proper controlling voltages are


        34                                LOVELY PROFESSIONAL UNIVERSITY
   35   36   37   38   39   40   41   42   43   44   45