A fast integer line-drawing algorithm invented by Jack Bresenham, or one of a family of algorithms derived from the original.
Questions tagged [bresenham]
173 questions
43
votes
2 answers
Bresenham algorithm in Javascript
I need a fast algorithm for calculating coordinates for a line between two points. I tried to find good JavaScript Bresenham implementation, but there are too many and quite confusing publications. In wikipedia - here the fastest and most simple…

Boris Hamanov
- 3,085
- 9
- 35
- 58
14
votes
4 answers
A* heuristic to create Bresenham lines
From what I understand about A* heuristics and how the Bresenham algorithm works, this may not be be possible since only the current state and goal state are passed to the heuristic function. But maybe someone has a clever solution to this…

peskal
- 1,213
- 1
- 12
- 28
13
votes
2 answers
Simplified Bresenham's line algorithm: What does it *exactly* do?
Based on Wikipedia's article on Bresenham's line algorithm I've implemented the simplified version described there, my Java implementation looks like this:
int dx = Math.abs(x2 - x1);
int dy = Math.abs(y2 - y1);
int sx = (x1 < x2) ? 1 : -1;
int sy…

riwi
- 549
- 1
- 6
- 16
13
votes
3 answers
Implementing Bresenham's circle drawing algorithm
I have written an implementation of Bresenham's circle drawing algorithm. This algorithms takes advantage of the highly symmetrical properties of a circle (it only computes points from the 1st octant and draws the other points by taking advantage of…

alainlompo
- 4,414
- 4
- 32
- 41
12
votes
3 answers
Algorithm for drawing a 4-connected line
I'm looking for an algorithm (coded in Java would be nice, but anything clear enough to translate to Java is fine) to draw a 4-connected line. It seems that Bresenham's algorithm is the most widely used, but all the understandable implementations…

elhefe
- 3,404
- 3
- 31
- 45
12
votes
2 answers
Precise subpixel line drawing algorithm (rasterization algorithm)
I need an algorithm which can be (a bit) slower than the Bresenham line drawing algorithm but has to be a lot more exact. With 'exact' I mean: every touched pixel should be printed. No more, but also no less! Which means using a more thick line or…

Karussell
- 17,085
- 16
- 97
- 197
12
votes
1 answer
All cases covered Bresenham's line-algorithm
I need to check all pixels in a line, so I'm using Bresenham's algorithm to access each pixel in it. In particular I need to check if all pixels are located on valid pixel of a bitmap. This is the code:
private void Bresenham(Point p1, Point p2, ref…

Frank Lioty
- 949
- 3
- 10
- 17
10
votes
3 answers
Drawing lines with Bresenham's Line Algorithm
My computer graphics homework is to implement OpenGL algorithms using only the ability to draw points.
So obviously I need to get drawLine() to work before I can draw anything else. drawLine() has to be done using integers only. No floating…

ToastyMallows
- 4,203
- 5
- 43
- 52
9
votes
5 answers
Walk a line between two points in a 3D voxel space visiting all cells
I have a line-of-sight problem I need to solve by visiting all possible cells in a 3D voxel space between two (non-grid-aligned) points.
I have considered using a 3D Bresenham algorithm, but it will skip out some cells.
A naive implementation might…

Wivlaro
- 1,455
- 1
- 12
- 18
7
votes
2 answers
c++ Bresenham's line algorithm draw arc and rotate
I'm searching way to make arc with Bresenham's line algorithm. This algoritm draw perfect circle, but what if i need draw arc (from 0 to Pi) and rotate it for 30 degrees (for example)?
void DrawCircle(HDC hdc,int x0, int y0, int radius)
{
…

PePe
- 443
- 2
- 5
- 15
6
votes
2 answers
How to use Bresenham's line drawing algorithm with clipping?
When drawing a line with Bresenham line drawing algorithm,
where the line may not be within the bounds of the bitmap being written to - it would be useful to clip the results so they fit within the axis aligned bounds of the image being written…

ideasman42
- 42,413
- 44
- 197
- 320
6
votes
2 answers
Circle with thickness drawing algorithm
Currently I am using Bresenham's circle drawing algorithm, which draws circles fine, however I would like a relatively fast and efficient way to draw a circle with a specified thickness (since Bresenham's method only draws a single pixel thickness).…
user3792326
5
votes
1 answer
Iterating through every pixel in concentric circles
I am trying to iterate through every pixel coordinate, starting at (0, 0), in order to fuse two pixelated shapes at the closest offset where they don't overlap.
Until now, I was using concentric squares, which are really easy to do but can end up…

ice-wind
- 690
- 4
- 20
5
votes
1 answer
Draw all voxels that pass through a 3D line in 3D voxel space
I want to draw a 3D voxelized line, that is, to find all the voxels which a line passes. 3D bresenham always skips some voxels. As shown in the figure, the voxels generated by 3D bresenham cannot completely contain the line between the start voxel…

yaqian chen
- 101
- 4
5
votes
5 answers
Asteroids Game Movement In C#
I am trying to make the game Asteroids. My issue I have right now, is if you press the UP Arrow key, it will move the "ship" 10 pixels up. And if you hit the LEFT Arrow key, it will turn the "ship" 5 degrees to the left, the issue I have comes into…

Cistoran
- 1,587
- 15
- 36
- 54