bresenham

All cases covered Bresenham's line-algorithm [closed]

妖精的绣舞 提交于 2019-11-27 08:46:41
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 List<Point> track) { int dx = p2.X - p1.X; int dy = p2.Y - p1.Y; int swaps = 0; if (dy > dx) { Swap(ref dx, ref dy); swaps = 1; } int a = Math.Abs(dy); int b = -Math.Abs(dx); double d = 2*a + b; int x = p1.X; int y = p1.Y; color_track = Color.Blue; Check_Pixel(ref area, new Point(x,y)); track.Clear(); track.Add(new Point(x, y)); int s = 1; int q =

Walk a line between two points in a 3D voxel space visiting all cells

最后都变了- 提交于 2019-11-27 02:53:36
问题 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 be to just check points along the line at a higher resolution than the voxel grid, but I was hoping for a more intelligent solution. Anyone got any leads? 回答1: Came up with this, or see: http://jsfiddle.net/wivlaro/mkaWf/6/ function visitAll(gx0,

Bresenham algorithm in Javascript

≡放荡痞女 提交于 2019-11-26 20:08:54
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 form (no divisions and error calculation for both directions) is presented in pseudocode like this: function line(x0, y0, x1, y1) dx := abs(x1-x0) dy := abs(y1-y0) if x0 < x1 then sx := 1 else sx := -1 if y0 < y1 then sy := 1 else sy := -1 err := dx-dy loop setPixel(x0,y0) if x0 = x1 and y0 = y1 exit loop e2 := 2*err if e2 > -dy then err := err - dy x0

algorithm to rasterize and fill a hypersphere?

回眸只為那壹抹淺笑 提交于 2019-11-26 18:35:16
问题 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 Midpoint circle algorithm which takes advantage of 8-way mirroring and produces the outer cells (border) of a circle. I have also altered the linked wikipedia code so as to fill the circle (that is, to produce the coordinates of all cells inside the

All cases covered Bresenham&#39;s line-algorithm [closed]

牧云@^-^@ 提交于 2019-11-26 14:17:56
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . 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

Precise subpixel line drawing algorithm (rasterization algorithm)

不打扰是莪最后的温柔 提交于 2019-11-26 09:02:47
问题 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 similar is not an option as too many pixels will be involved. Also I don\'t need a graphic framework or similar like it was asked before, I need the algorithm! The application is not really in \'graphics\' it is in the geography area where pixels

Bresenham algorithm in Javascript

假装没事ソ 提交于 2019-11-26 07:30:43
问题 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 form (no divisions and error calculation for both directions) is presented in pseudocode like this: function line(x0, y0, x1, y1) dx := abs(x1-x0) dy := abs(y1-y0) if x0 < x1 then sx := 1 else sx := -1 if y0 < y1 then sy := 1 else sy := -1 err := dx