Questions tagged [bresenham]

A fast integer line-drawing algorithm invented by Jack Bresenham, or one of a family of algorithms derived from the original.

173 questions
5
votes
2 answers

Line Rasterization / 4-connected Bresenham

For collision testing I need to raster a line. The bresenham algorithm works almost as desired, but has the flaw that is produces a line like: And I need: My current implementation (based on…
DiddiZ
  • 625
  • 8
  • 17
4
votes
1 answer

algorithm to rasterize and fill a hypersphere?

I'm trying to rasterize and fill a hypersphere. In essence, I have a d-dimensional grid of fixed size and a sphere (center, radius) and want to find out which cells of the grid overlap with the sphere and store their coordinates. I am aware of the…
aeolist
  • 196
  • 9
4
votes
0 answers

Anti-aliasing - Unweighted Area Sampling

I am currently trying to incorporate anti-aliasing into my line drawing algorithms (DDA and Bresenham), I have been instructed by the professor that any anti-aliasing technique is allowed so I did some research and it seems that Unweighted Area…
Belphegor
  • 1,683
  • 4
  • 23
  • 44
4
votes
3 answers

How to use Bresenham's line drawing algorithm with sub pixel bias?

Bresenham's line drawing algorithm is well known and quite simple to implement. While there are more advanced ways to draw anti-ailesed lines, Im interested in writing a function which draws a single pixel width non anti-aliased line, based on…
ideasman42
  • 42,413
  • 44
  • 197
  • 320
4
votes
3 answers

My implementation of Bresenham's algorithm fails for lines at certain angles

I've written an implementation of Bresenham's algorithm in Python (following the Wikipedia article), and it works correctly except for lines at certain angles. All lines that should extend between 45 and 90 degrees, or between 135 and 270 degrees,…
Max
  • 1,295
  • 6
  • 16
  • 31
4
votes
3 answers

please explain this Bresenham Line drawing code for me

I have searched throughout the Internet and found hundreds of implementation of Bresenham's line drawing algorithm. But, one thing I found strange is, only two or three of them can cover all of the eight octets. still, they are being used in many…
user366312
  • 16,949
  • 65
  • 235
  • 452
4
votes
2 answers

efficient algorithm for drawing circle arcs?

I am using the mid-point circle algorithm (bresenham circle) to efficiently draw whole circles. Is there something similar to draw circle arcs? I would like to specify a start angle and end angle and have only that portion of the circle…
horseyguy
  • 29,455
  • 20
  • 103
  • 145
4
votes
5 answers

Bresenham concentric circles leaving empty pixels

I am using the midpoint circle algorithm, also known as Bresenham's, to draw concentric circles. The difference between each circle's radius and that of the next is always 1, so the final result should be a full circular area. However, some pixels…
cangrejo
  • 2,189
  • 3
  • 24
  • 31
3
votes
1 answer

Why Bresenham's line algorithm more efficent then Naive algorithm

For my graphics course we were taught the Naive line rasterizing algorithm then Bresenham's line drawing algorithm. We were told computers are integer machines which is why we should use the latter. If we assume no optimization on software level…
Jan Omer
  • 33
  • 1
  • 3
3
votes
1 answer

How to make Bresenham algorithm working backward?

I got an exersise where I would like to draw a line with Bressenham algorithm. The thing is that it's working perfectly for lines who goes down and on the right, but when the line goes up or backward, it doesn't work anymore ... Does anybody can…
rpoder
  • 53
  • 4
3
votes
2 answers

bresenham's line algorithm error

I had the following code of bresenham's algorithm which represents adapted to Scala Java code. def bresenham(x0: Int, y0: Int, x1: Int, y1: Int) = { import scala.math.abs val dx = abs(x1 - x0) val dy = abs(y1 - y0) val sx = if (x0…
om-nom-nom
  • 62,329
  • 13
  • 183
  • 228
3
votes
0 answers

Can you explain this Bresenham's Circle implementation?

I'm studying a paper in which the author claims to use Bresenham circles to scan the area around a pixel efficiently. I studied the algorithm but the equations used in most websites I've seen are way different from the author's implementation. Have…
John Katsantas
  • 571
  • 6
  • 20
3
votes
1 answer

How to implement Bresenham's line algorithm in C when trying to draw a line in bmp file?

I am trying to draw a User-answer-based line in a bmp file. To do that, I represent the pixels of the file in a Matrix variable. after reading the Bresenham's line algorithm value in Wikipedia, and rosettacode examples, I am not sure if I fully…
oferb
  • 91
  • 5
3
votes
1 answer

What's the basic difference between the following two implementations?

I was trying to use opengl using c. The code which I wrote leaves gaps within the lines i.e. draws dotted lined whereas the one which I found on the net draws perfectly. I don't get that, if there is no difference in the code which I wrote and the…
user8704383
3
votes
0 answers

Line and bitmap collision detection

I am trying to implement an efficient collision detection between a line joining two points and a bitmap mask. Example: Currently I am using Bresenham's line drawing algorithm to draw each pixel of the line between the two points and comparing that…
Alessi 42
  • 1,112
  • 11
  • 26
1
2
3
11 12