Digital differential analyzer (graphics algorithm): Difference between revisions

Content deleted Content added
m Added Turbo C++ in the description. The program doesn't work in modern C++.
No edit summary
Line 3:
In [[computer graphics]], a '''digital differential analyzer''' ('''DDA''') is hardware or software used for [[interpolation]] of [[Variable (computer science)|variables]] over an [[Interval (mathematics)|interval]] between start and end point. DDAs are used for [[rasterization]] of lines, triangles and polygons. They can be extended to non linear functions, such as [[texture mapping#Perspective correctness|perspective correct texture mapping]], [[quadratic curves]], and traversing [[voxels]].
 
In its simplest implementation for linear cases such as [[Line (geometry)|line]]s, the DDA algorithm interpolates values in interval by computing for each x<sub>i</sub> the equations x<sub>i</sub> = x<sub>i−1</sub> + 1, y<sub>i</sub> = y<sub>i−1</sub> + m, where Δxm =is x<sub>end</sub>the [[slope]] x<sub>start</sub>of andthe line. Δy =This y<sub>end</sub>slope can y<sub>start</sub>be andexpressed min DDA =as Δy/Δxfollows:
 
:<math>m = \frac{y_{\rm end} -y_{\rm start}}{x_{\rm end}-x_{\rm start}}</math>
== Performance ==
 
where ''m'' represents the slope of the line and ''c'' is the y intercept. In fact any two consecutive pointpoints (x,y) lying on this line segment should satisfy the equation.
 
== Performance ==
The DDA method can be implemented using [[floating-point]] or [[integer]] arithmetic. The native floating-point implementation requires one addition and one rounding operation per interpolated value (e.g. coordinate x, y, depth, color component etc.) and output result. This process is only efficient when an [[Floating-point unit|FPU]] with fast add and rounding operation will be available.
 
Line 12 ⟶ 15:
 
DDAs are well suited for hardware implementation and can be pipelined for maximized throughput.
 
This slope can be expressed in DDA
as
:<math>m = \frac{y_{\rm end} -y_{\rm start}}{x_{\rm end}-x_{\rm start}}</math>
where ''m'' represents the slope of the line and ''c'' is the y intercept. In fact any two consecutive point(x,y) lying on this line segment should satisfy the equation.
 
== Algorithm ==