File Exchange

image thumbnail

Bresenham optimized for Matlab

version 1.1.0.0 (1.4 KB) by Aaron Wetzler
An implementation of the classic algorithm with code optimized for Matlab

23 Downloads

Updated 15 Jul 2010

View Version History

View License

This code does not use any for loops and takes advantage of Matlabs internally optimized routines to produce a fast, optimized version of Bresenham's line drawing algorithm

Cite As

Aaron Wetzler (2021). Bresenham optimized for Matlab (https://www.mathworks.com/matlabcentral/fileexchange/28190-bresenham-optimized-for-matlab), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

Milena Mori

Lucyanno Frota

Mohsen

Shuvo Sarker

Readability is not so good! But I appreciate your work. Thanks.

William Chamberlain

Missing a couple of terminating ';', but I don't care _because it works_ .

John Doe

Geoffrey Vincent

Excellent, especially because he will work with negative values!

Gerhard Keuck

SAASTN

I believe cumsum(q) is equivalent to round(0:(dy/dx):dy), anyway, I posted some code at: stackoverflow.com/a/43726466/2093077 that uses same logic but is about 20% faster.

Sushant Kulkarni

Toby

Jordi Palacin

im577

q=[0;diff(mod([floor(dx/2):-dy:-dy*dx+floor(dx/2)]',dx))>=0]
What does this equation mean?

Aaron

Very efficient, and well made. Code comments messy, and lines not terminated with ;.

Aaron

Christian Wengert

compact and elegant implementation

MATLAB Release Compatibility
Created with R14
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!