Docs: Improve docstring for DDA algorithm (#13906)

* Docs: Improve docstring for DDA algorithm

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Apply suggestion from @cclauss

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix typo in DDA algorithm description

Corrected a typo in the comment regarding the DDA algorithm.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Jeanne Boussonnière
2026-09-21 23:29:44 +02:00
committed by GitHub
co-authored by pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Christian Clauss
parent 311cccafd5
commit d059c70867
@@ -21,6 +21,15 @@ def digital_differential_analyzer_line(
Despite this, DDA is useful for educational purposes as it is simple
to understand and demonstrates the basic idea of incremental line generation.
This algorithm works by calculating the dx (change in x) and dy (change in y) and
then iteratively steps along the dominant axis, incrementing the other axis by a
fractional amount (the slope).
It is notable for its simplicity but also for its main disadvantage:
* it relies on floating-point arithmetic at every step, which is computationally
slow.
* it is generally outperformed by Bresenham's algorithm, which achieves the same
result using only integer-based math.
Args:
- p1: Coordinates of the starting point.
- p2: Coordinates of the ending point.