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

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.

Text Clipping

“Text Clipping is a process in which we remove those part (portion) of string that is outside the view pane (window).” Various methods and techniques can do the text clipping. These techniques depend...

2 minutes 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.

Input Devices in Computer Graphics

An Input device is the piece of computer hardware equipment used to give input to the computer. The input can be in the form of graphics, text, sound, audio, video,...

7 minutes read.

2D Scaling

In scaling, we can expend or compress the size of any object. We can apply scaling on the object by multiplying the original coordinates with scaling factors. The term scaling factor...

2 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.

Display Devices in Computer Graphics

The display device is an output device used to represent the information in the form of images (visual form). Display systems are mostly called a video monitor or Video display unit (VDU). Display devices are designed to model, display, view, or display information. The...

6 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.

3D Translation

A 3D Translation process contains the x-axis, y-axis, and z-axis. We can move any object from one place to another without changing the shape of the object. For Example-Translation of a...

1 minute 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.

Point Clipping

“Point clipping is a process which is used to define the point position.” The point is either inside the view pane (window) or outside the view pane. In computer graphics, the computer...

2 minutes read.

2D Rotation

The Rotation of any object depends upon the two points. Rotation Point: It is also called the Pivot point. Rotation Angle: It is denoted by Theta (). We can rotate an object in...

1 minute 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.

Computer Graphics Tutorial

Introduction to Computer Graphics Computer graphics is commonly seen as a computer science branch that deals with the computerized image fusion theory and technology. As simple as a triangle outline, a...

6 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.

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.

Polygon Clipping in Computer Graphics

“A Polygon can be described as the enclosed collection or group of the lines.” In a polygon, all lines are connected. Lines can be a combination of edges and vertices,...

4 minutes read.

Image Representation in Computer Graphics

Image Representation: In computer science, we can represent an image in various forms. Most of the time, it refers to the way that brings information, such as color is coded digitally, and...

4 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.

3D Reflection

The Reflection is a mirror image of the original object. We can differentiate 2D and 3D reflection by adding Z-axis. The Z-axis shows the depth of the surface. In the...

1 minute read.