Line Drawing Algorithm in Computer Graphics

“The Line drawing algorithm is a graphical algorithm which is used to represent the line segment on discrete graphical media, i.e., printer and pixel-based media.”

A line contains two points. The point is an important element of a line.

Properties of a Line Drawing Algorithm

There are the following properties of a good Line Drawing Algorithm.

  • An algorithm should be precise: Each step of the algorithm must be adequately defined.
  • Finiteness: An algorithm must contain finiteness. It means the algorithm stops after the execution of all steps.
  • Easy to understand: An algorithm must help learners to understand the solution in a more natural way.
  • Correctness: An algorithm must be in the correct manner.
  • Effectiveness: Thesteps of an algorithm must be valid and efficient.
  • Uniqueness: All steps of an algorithm should be clearly and uniquely defined, and the result should be based on the given input.
  • Input:  A good algorithm must accept at least one or more input.
  • Output: An algorithm must generate at least one output.

Equation of the straight line

We can define a straight line with the help of the following equation.

     y= mx + a

Where,

 (x, y) = axis of the line.

m = Slope of the line.

a = Interception point

Line Drawing Algorithm in Computer Graphics

Let us assume we have two points of the line (p1, q1) and (p2, q2).

Now, we will put values of the two points in straight line equation, and we get

 y = mx + a

q2 = mp2                                                                                                       ...(1)

q1 = mp1 + a                                                                                                 ...(2)

We have from equation (1) and (2)

q2 – q1 = mp2 ­– mp1

q2 – q1 = m (p2 ­–p1)

The value of m = (q2 – q1)/ (p2 ­–p1)

                       m = ?q / ?p

Algorithms of Line Drawing

 There are  following algorithms used for drawing a line:

  • DDA (Digital Differential Analyzer) Line Drawing Algorithm
  • Bresenham’s Line Drawing Algorithm
  • Mid-Point Line Drawing Algorithm

Related Topics

Clipping in Computer Graphics

“The Clipping is a type of transformation used in computer graphics to remove lines, objects, and segments of lines that are outside the computer screen or viewing pane.” The clipping is a...

2 minutes read.

Mid-Point Line Drawing Algorithm in Computer Graphics

The Mid-point Subdivision algorithm is the extension of the Cyrus-Beck algorithm. The Mid-Point line plotting algorithm was introduced by “Pitway and Van Aken.” It is an incremental line drawing algorithm....

8 minutes read.

Output Devices in Computer Graphics

Computer Graphics Output Devices An output device is a component of hardware or the main physical part of a computer that can be touched and seen. An output device is an electromechanical device. “The...

5 minutes read.

Panning

“Panning is a process or photographic technique that is used to combine slow shutter speed with camera movement to make a speed sense around the moving object.” We can define panning as...

2 minutes read.

Scan Conversion in Computer Graphics

“When we represent regular objects in the form of discrete pixels, it is called Scan Conversion.” Every graphics system must transform the primitives into a collection of pixels. The scan conversion is also...

2 minutes read.

History of Computer Graphics

History of Computer Graphics Computer Graphics (CG) was first developed as a visualization tool. Computer graphics were basically introduced for scientists and engineers in government and corporate research centers, i.e., Bell Labs and Boeing...

4 minutes read.

Scan Conversion of an Ellipse Computer Graphics

Scan Conversion of an Ellipse: An ellipse can be defined as a closed plane curve, which is a collection of points. It is the cause of the intersection of a...

8 minutes read.

Illumination Model in Computer Graphics

Illumination Model in Computer Graphics The series of methods used to depict light in computer graphics scenarios is computer graphics illumination. Although lighting strategies provide versatility in the degree of detail...

8 minutes read.

Projection in Computer Graphics

Projection Introduction: The technique projection was invented by the Swiss mathematician, engineer, and astronomer "Leonhard Euler Around" in 1756. The "Episcope" was the first projection system. “Projection is a technique or process which...

4 minutes read.

2D Shearing

We can denote shearing with ‘SHx’ and ‘SHy.’ These ‘SHx’ and ‘SHy’ are called “Shearing factor.” We can perform shearing on the object in two ways- Shearing along x-axis: In this, we...

2 minutes read.

Bresenham’s Line Drawing Algorithm in Computer Graphics

This algorithm was introduced by “Jack Elton Bresenham” in 1962. This algorithm helps us to perform scan conversion of a line. It is a powerful, useful, and accurate method. We...

8 minutes read.

Composite Transformation in Computer Graphics

Composite transformation in Computer Graphics It is possible to integrate a range of transformations or series of transformations into some kind of a single one which is known as composition. The...

6 minutes read.

2D Transformation in Computer Graphics

Some visuals are transformed into some other graphics by implementing several of the principles known as transformation. There are multiple kinds of transformation, including translation, scaling, rotation, shearing, etc. Whenever...

2 minutes read.

2D Translation

We can move any object from one to another place without changing the shape of the object. For Example- Translation of a Point:If we want to translate a point from P (x0,...

1 minute read.

Bresenham’s Circle Drawing Algorithm in Computer Graphics

Bresenham’s algorithm is also used for circle drawing. It is known as Bresenham’s circle drawing algorithm. It helps us to draw a circle. The circle generation is more complicated than...

11 minutes read.

Pointing and Positioning Technique Computer Graphics

Pointing and Positioning Technique: The pointing and positioning are interactions used in computer graphics. A pointing device is also called a Pointing tool. A pointing tool is a hardware component,...

4 minutes read.

Homogenous Coordinates in Computer Graphics

Homogenous Coordinates in Computer Graphics The orbit of a point, a line graph or the whole picture on the computer, a point besides the origin, is accomplished by first shifting the...

7 minutes read.

Aspect Ratio in Computer Graphics

Aspect Ratio in Computer Graphics You might well understand the concept of Aspect ratio as of now if you know regarding aerial photography or see the configuration portion of any computer...

5 minutes read.

Display Processor

It is a part of hardware or interpreter which is used to transform display processor code into pictures. It is used to convert digital information from CPU to analog data. It...

4 minutes read.

Computer Graphics Window

“The process of selecting and viewing an image with different views, called windowing.” All the objects in the real world have a size. We can measure the size and location of...

4 minutes read.