100% found this document useful (3 votes)
712 views8 pages

Mid Point Line Drawing Algorithm Explained

The mid point line drawing algorithm generates points between a starting and ending coordinate by calculating the change in X and Y values, initializing a decision parameter, and incrementing X or Y at each step based on the changing decision parameter value. It involves calculating the difference in X and Y coordinates, the initial decision parameter, and the decision parameter change. The algorithm then repeatedly increments X or Y at each step depending on whether the decision parameter is positive or negative.

Uploaded by

Ashley Maina
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
712 views8 pages

Mid Point Line Drawing Algorithm Explained

The mid point line drawing algorithm generates points between a starting and ending coordinate by calculating the change in X and Y values, initializing a decision parameter, and incrementing X or Y at each step based on the changing decision parameter value. It involves calculating the difference in X and Y coordinates, the initial decision parameter, and the decision parameter change. The algorithm then repeatedly increments X or Y at each step depending on whether the decision parameter is positive or negative.

Uploaded by

Ashley Maina
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
  • Mid Point Line Drawing Algorithm
  • Example Problem - 01
  • Example Problem - 02
  • Advantages of Mid Point Line Drawing Algorithm
  • Disadvantages of Mid Point Line Drawing Algorithm

Mid Point Line Drawing Algorithm-

Given the starting and ending coordinates of a line,


Mid Point Line Drawing Algorithm attempts to generate the points between the starting and ending
coordinates.

Also Read- DDA Line Drawing Algorithm

Procedure-

Given-
 Starting coordinates = (X0, Y0)
 Ending coordinates = (Xn, Yn)

The points generation using Mid Point Line Drawing Algorithm involves the following steps-

Step-01:

Calculate ΔX and ΔY from the given input.


These parameters are calculated as-
 ΔX = Xn – X0
 ΔY =Yn – Y0

Step-02:

Calculate the value of initial decision parameter and ΔD.


These parameters are calculated as-
 Dinitial = 2ΔY – ΔX
 ΔD = 2(ΔY – ΔX)
Step-03:

The decision whether to increment X or Y coordinate depends upon the flowing values of Dinitial.
Follow the below two cases-

Step-04:

Keep repeating Step-03 until the end point is reached.


For each Dnew value, follow the above cases to find the next coordinates.

PRACTICE PROBLEMS BASED ON MID POINT LINE DRAWING ALGORITHM-

Problem-01:

Calculate the points between the starting coordinates (20, 10) and ending coordinates (30, 18).
Solution-

Given-
 Starting coordinates = (X0, Y0) = (20, 10)
 Ending coordinates = (Xn, Yn) = (30, 18)

Step-01:

Calculate ΔX and ΔY from the given input.


 ΔX = Xn – X0 = 30 – 20 = 10
 ΔY =Yn – Y0 = 18 – 10 = 8

Step-02:

Calculate Dinitial and ΔD as-


 Dinitial = 2ΔY – ΔX = 2 x 8 – 10 = 6
 ΔD = 2(ΔY – ΔX) = 2 x (8 – 10) = -4

Step-03:

As Dinitial >= 0, so case-02 is satisfied.

Thus,
 Xk+1 = Xk + 1 = 20 + 1 = 21
 Yk+1 = Yk + 1 = 10 + 1 = 11
 Dnew = Dinitial + ΔD = 6 + (-4) = 2
Similarly, Step-03 is executed until the end point is reached.

Dinitial Dnew Xk+1 Yk+1

20 10

6 2 21 11

2 -2 22 12

-2 14 23 12

14 10 24 13

10 6 25 14

6 2 26 15

2 -2 27 16

-2 14 28 16

14 10 29 17

10 30 18
Problem-02:

Calculate the points between the starting coordinates (5, 9) and ending coordinates (12, 16).

Solution-

Given-
 Starting coordinates = (X0, Y0) = (5, 9)
 Ending coordinates = (Xn, Yn) = (12, 16)

Step-01:

Calculate ΔX and ΔY from the given input.


 ΔX = Xn – X0 = 12 – 5 = 7
 ΔY =Yn – Y0 = 16 – 9 = 7

Step-02:

Calculate Dinitial and ΔD as-


 Dinitial = 2ΔY – ΔX = 2 x 7 – 7 = 7
 ΔD = 2(ΔY – ΔX) = 2 x (7 – 7) = 0

Step-03:

As Dinitial >= 0, so case-02 is satisfied.

Thus,
 Xk+1 = Xk + 1 = 5 + 1 = 6
 Yk+1 = Yk + 1 = 9 + 1 = 10
 Dnew = Dinitial + ΔD = 7 + 0 = 7

Similarly, Step-03 is executed until the end point is reached.

Dinitial Dnew Xk+1 Yk+1

5 9

7 7 6 10

7 7 7 11

7 7 8 12

7 7 9 13
7 7 10 14

7 7 11 15

7 12 16

Advantages of Mid Point Line Drawing Algorithm-

The advantages of Mid Point Line Drawing Algorithm are-


 Accuracy of finding points is a key feature of this algorithm.
 It is simple to implement.
 It uses basic arithmetic operations.
 It takes less time for computation.
 The resulted line is smooth as compared to other line drawing algorithms.

Also Read- Bresenham Line Drawing Algorithm


Disadvantages of Mid Point Line Drawing Algorithm-

The disadvantages of Mid Point Line Drawing Algorithm are-


 This algorithm may not be an ideal choice for complex graphics and images.
 In terms of accuracy of finding points, improvement is still needed.
 There is no any remarkable improvement made by this algorithm.

Common questions

Powered by AI

The algorithm shows limited improvements in accuracy due to its fixed approach toward handling line paths, which might not adapt well to dynamic or non-linear shapes where incremental approximations do not suffice for maintaining precision .

The algorithm, though accurate and simple, is not well-suited for complex graphics due to its limitations in handling intricate details and the precision required for more detailed patterns and images. It also doesn't have significant improvements over other algorithms, which might impact its effectiveness in complex scenarios .

The algorithm increments both X and Y coordinates when the decision parameter Dnew meets or exceeds zero. This scenario satisfies the condition where the midpoint's Y-coordinate is higher than the actual line, necessitating an upward shift to maintain approximation accuracy .

The initial steps involve calculating ΔX and ΔY using the given starting and ending coordinates. Specifically, ΔX is calculated as Xn – X0, and ΔY as Yn – Y0. Then, the initial decision parameter Dinitial is calculated as 2ΔY – ΔX, and ΔD is calculated as 2(ΔY – ΔX).

In the algorithm, the final Y coordinate is incremented when the decision parameter Dnew for the next step remains positive or zero after an X increment, indicating the need to move up a row to stay close to the line trajectory. This guarantees the line accurately reflects the desired endpoint .

The advantages include accuracy in finding points, simplicity of implementation, reliance on basic arithmetic operations, reduced computation time, and production of smoother lines compared to other line drawing algorithms .

The algorithm's efficiency in computation arises from its reliance on simple arithmetic operations and straightforward decision parameters, which reduce computational overhead and processing time compared to more complex algorithms involving floating-point calculations .

The decision parameter determines whether the X or Y coordinate should be incremented. If the decision parameter Dnew is greater than or equal to 0, both X and Y are incremented, otherwise only X is incremented, ensuring the line follows the closest grid path to the ideal trajectory .

The initial decision parameter Dinitial establishes the initial direction of the line, determining whether to increment the Y-coordinate immediately or just the X-coordinate. ΔD, calculated as 2(ΔY – ΔX), influences subsequent Dnew calculations, impacting whether future steps should involve simultaneous X and Y increments to ensure the path remains true to the intended line direction from start to finish .

The algorithm ensures smoothness by using basic arithmetic operations to calculate the closest approximation to a straight line on a grid, minimizing sharp deviations in the pixel path, which results in smoother appearances compared to more complex methods that might introduce errors .

Mid Point Line Drawing Algorithm-
 
Given the starting and ending coordinates of a line,
Mid Point Line Drawing Algorithm att
Step-03:
 
The decision whether to increment X or Y coordinate depends upon the flowing values of Dinitial.
Follow the below
Solution-
 
Given-

Starting coordinates = (X0, Y0) = (20, 10)

Ending coordinates = (Xn, Yn) = (30, 18)
 
Step-01:
 
Calcu
Similarly, Step-03 is executed until the end point is reached.
 
Dinitial
Dnew
Xk+1
Yk+1
20
10
6
2
21
11
2
-2
22
12
-2
14
23
 
Problem-02:
 
Calculate the points between the starting coordinates (5, 9) and ending coordinates (12, 16).
 
Solution-
 
G

ΔX = Xn – X0 = 12 – 5 = 7

ΔY =Yn – Y0 = 16 – 9 = 7
 
Step-02:
 
Calculate Dinitial and ΔD as-

Dinitial = 2ΔY – ΔX = 2 x
7
7
10
14
7
7
11
15
7
12
16
 
 
Advantages of Mid Point Line Drawing Algorithm-
 
The advantages of Mid Point Line Drawing Al
 
Disadvantages of Mid Point Line Drawing Algorithm-
 
The disadvantages of Mid Point Line Drawing Algorithm are-

This algo

You might also like