Function Repository Resource:

# BresenhamPoints

Calculate integer 2D point locations along a line using Bresenham's method

Contributed by: Flip Phillips (https://flipphillips.com)
 ResourceFunction["BresenhamPoints"][p1,p2] computes integer point locations along the line from p1 to p2.

## Details

p1 and p2 are 2D points with integer coordinates.
The algorithm for these computations is known as Bresenham's method.
ResourceFunction["BresenhamPoints"][{p1,p2}] and ResourceFunction["BresenhamPoints"][Line[{p1,p2}]] are equivalent to ResourceFunction["BresenhamPoints"][p1,p2].

## Examples

### Basic Examples (1)

Compute the points on the line from {2,3} to {7,9}:

 In[1]:=
 Out[1]=

### Scope (1)

Use BresenhamPoints on a Line object:

 In[2]:=
 Out[2]=

### Applications (2)

Visualize a line and its corresponding Bresenham points together:

 In[3]:=
 Out[3]=

Use Raster to visualize the Bresenham points:

 In[4]:=
 Out[4]=

### Neat Examples (1)

Extract points from an image along an arbitrary line:

 In[5]:=
 In[6]:=
 Out[6]=
 In[7]:=
 Out[7]=

Flip Phillips

## Version History

• 1.0.0 – 16 August 2021