Here is an implementation of the Bresenham Algorithm in MATLAB for drawing a line between two points (x1,y1
) and (x2,y2
).
main.m782 chars53 lines
To test the algorithm, call it with the starting and ending point coordinates:
main.m65 chars7 lines
This will return arrays of x
and y
coordinates that you can use to plot the line:
main.m10 chars2 lines
This will draw a line between the points (2,3)
and (9,8)
using the Bresenham Algorithm.
gistlibby LogSnag