What is the algorithm for drawing line on the plane (pointwise), if it is not horizontal or vertical?
Bresenham's line algorithm is a line drawing algorithm that determines the points of an n-dimensional raster that should be selected in order to form a close approximation to a straight line between two points.
The Digital Difference Analyzer (DDA) algorithm is used to draw lines on a screen in an incrementally. The algorithm is called the Digital Difference Analyzer because it interpolates points based on the difference between the start and end points. The algorithm itself is very easy to understand and implement.
Advantages of Bresenham Line Drawing Algorithm- It is easy to implement. It is fast and incremental. It executes fast but less faster than DDA Algorithm. The points generated by this algorithm are more accurate than DDA Algorithm.
See Bresenham's algorithm.
There is no 'pointwise' algorithm - points are infinitesimally small, so any algorithm based on points would take an infinite time to complete.
Instead, lines are drawn based on a notional pen width and calculating how many and what intensity of pixels that stroking the line with a pen would cover.
If you merely want to turn pixels on and off like it's the 1970s, then use one of the Brensenham's algorithm family.
Most modern computer graphics use anti-aliasing algorithms - either stroking, sub-sampling or exact pixel coverage - and sometimes parallel algorithms in the GPU ( for example drawing a line by projecting a thin rectangle onto the plane, or performing coverage calculations per pixel in parallel ).
Many graphics algorithms are based on Bezier curves; straight lines are just curves where the control points are in a line, so the algorithms for drawing them are the same, though may make a few optimisations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With