Skip to content

Commit 76713b0

Browse files
authored
Refactor docstring for digital_differential_analyzer_line
Updated the docstring to clarify the DDA algorithm description and removed redundant references.
1 parent fe84e1e commit 76713b0

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

graphics/digital_differential_analyzer_line.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
# https://en.wikipedia.org/wiki/Digital_differential_analyzer_(graphics_algorithm)
2+
13
import matplotlib.pyplot as plt
24

35

46
def digital_differential_analyzer_line(
57
p1: tuple[int, int], p2: tuple[int, int]
68
) -> list[tuple[int, int]]:
79
"""
8-
910
Digital Differential Analyzer (DDA) Line Drawing Algorithm.
1011
11-
This algorithm draws a straight line between two points by calculating
12-
the difference in x (dx) and y (dy) coordinates and incrementally stepping
13-
through the dominant axis while updating the other axis using fractional
14-
increments.
12+
Draw a straight line between two points by calculating the difference in
13+
x (dx) and y (dy) coordinates and incrementally stepping through the
14+
dominant axis while updating the other axis using fractional increments.
1515
1616
One of the main disadvantages of the DDA algorithm is its reliance on
1717
floating-point arithmetic, which can introduce rounding errors at each step.
@@ -21,20 +21,14 @@ def digital_differential_analyzer_line(
2121
Despite this, DDA is useful for educational purposes as it is simple
2222
to understand and demonstrates the basic idea of incremental line generation.
2323
24-
References:
25-
- https://en.wikipedia.org/wiki/Digital_differential_analyzer_(graphics_algorithm)
26-
27-
28-
29-
30-
Args:
31-
- p1: Coordinates of the starting point.
32-
- p2: Coordinates of the ending point.
33-
Returns:
34-
- List of coordinate points that form the line.
24+
Args:
25+
- p1: Coordinates of the starting point.
26+
- p2: Coordinates of the ending point.
27+
Returns:
28+
- List of coordinate points that form the line.
3529
36-
>>> digital_differential_analyzer_line((1, 1), (4, 4))
37-
[(2, 2), (3, 3), (4, 4)]
30+
>>> digital_differential_analyzer_line((1, 1), (4, 4))
31+
[(2, 2), (3, 3), (4, 4)]
3832
"""
3933
x1, y1 = p1
4034
x2, y2 = p2

0 commit comments

Comments
 (0)