Digital differential analyzer (graphics algorithm)
In computer graphics, a digital differential analyzer (DDA) is hardware or software used for interpolation of variables over an interval between start and end point.[src] DDAs are used for rasterization of lines, triangles and polygons.[src] They can be extended to non linear functions, such as perspective correct texture mapping, quadratic curves, and traversing voxels.[src] In its simplest implementation for linear cases such as lines, the DDA algorithm interpolates values in interval by computing for each x i the equations x i = x i−1 + 1, y i = y i−1 + m, where m is the slope of the line.[src] This slope can be expressed in DDA as follows: : m = \frac{y_{\rm end} -y_{\rm start}}{x_{\rm end}-x_{\rm start}} In fact any two consecutive points lying on this line segment should satisfy the equation.[src]
In computer graphics, a digital differential analyzer (DDA) is hardware or software used for interpolation of variables over an interval between start and end point.[src] DDAs are used for rasterization of lines, triangles and polygons.[src] They can be extended to non linear functions, such as perspective correct texture mapping, quadratic curves, and traversing voxels.[src] In its simplest implementation for linear cases such as lines, the DDA algorithm interpolates values in interval by computing for each x i the equations x i = x i−1 + 1, y i = y i−1 + m, where m is the slope of the line.[src] This slope can be expressed in DDA as follows: m = \frac{y_{\rm end} -y_{\rm start}}{x_{\rm end}-x_{\rm start}} In fact any two consecutive points lying on this line segment should satisfy the equation.[src] Considering a line with positive slope, if the slope is less than or equal to 1, we sample at unit x intervals (dx=1) and compute successive y values as y_{k+1} = y_k + m x_{k+1} = x_k + 1 Subscript k takes integer values starting from 0, for the 1st point and increases by 1 until endpoint is reached.[src] y value is rounded off to nearest integer to correspond to a screen pixel.[src] For lines with slope greater than 1, we reverse the role of x and y i.e.[src] we sample at dy=1 and calculate consecutive x values as x_{k+1} = x_k + \frac{1}{m} y_{k+1} = y_k + 1 Similar calculations are carried out to determine pixel positions along a line with negative slope.[src] Thus, if the absolute value of the slope is less than 1, we set dx=1 if x_{\rm start} i.e.[src] the starting extreme point is at the left.[src] include include include include include void main() { float x, float y, float x1, y1, float x2, y2, dx, dy, step; int i, gd = DETECT, gm; initgraph(&gd, &gm, "C:\\TURBOC3\\BGI"); cout > x1 >> y1; cout > x2 >> y2; dx = (x2 - x1); dy = (y2 - y1); if (abs(dx) >= abs(dy)) step = abs(dx); else step = abs(dy); dx = dx / step; dy = dy / step; x = x1; y = y1; i = 0; while (i[src]
17 sentences · 17 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Digital differential analyzer (graphics algorithm)." encyclopegia.org, 2026, https://encyclopegia.org/wiki/digital-differential-analyzer-graphics-algorithm. Accessed 02 December 2026.
Chicago
"Digital differential analyzer (graphics algorithm)." encyclopegia.org. Accessed December 2, 2026. https://encyclopegia.org/wiki/digital-differential-analyzer-graphics-algorithm.
APA
encyclopegia.org. (2026). Digital differential analyzer (graphics algorithm). Retrieved December 2, 2026, from https://encyclopegia.org/wiki/digital-differential-analyzer-graphics-algorithm
Accessed December 2, 2026 · CC BY-SA 4.0 · citation page · JSON