LINES!!

Started by
5 comments, last by MattS423 21 years, 4 months ago
Can someone expalin Brensenham''s line algorithm? thanks.
Programmers of the world, UNTIE!
Advertisement
STFW.

Don''t listen to me. I''ve had too much coffee.
Bookah! As if by magic...

http://www.gamedev.net/reference/articles/article767.asp
thats a great article...but it''s in pascal..

thats fine, (i think i can manage to translate), but what is the C++ equivelent of the := operator?

I have a fealing it''s += but i''m not sure.

thanks.
Programmers of the world, UNTIE!
equivelent of := is =
not +=
Found this great thing on the Internet called Google. Took 2 tenths of a second to use and gave over 5000 results back. Here is the first page.
quote:Google search results
Searched the web for Bresenham algorithm. Results 1 - 10 of about 5,070. Search took 0.19 seconds.


Category: Computers > Programming > ... > Collision Detection > Software


Bresenham''s algorithm
Definition of Bresenham''s algorithm, possibly with links to more information
and implementations. NIST. Bresenham''s algorithm. (algorithm). ...
www.nist.gov/dads/HTML/bresenham.html - 4k - Cached - Similar pages

The Bresenham Line-Drawing Algorithm
... Algorithm. The basic Bresenham algorithm. ... Here is a C++ implementation of
the Bresenham algorithm for line segments in the first octant. void ...
www.cs.helsinki.fi/group/goa/ mallinnus/lines/bresenh.html - 9k - Cached - Similar pages

[PDF]The Ubiquitous Bresenham Algorithm as a Basis for Graphics ...
File Format: PDF/Adobe Acrobat - View as HTML
The Ubiquitous Bresenham Algorithm as a Basis for Graphics Interpolation Processes
Steve Cunningham California State University Stanislaus rsc@csustan.edu ...
www.cs.csustan.edu/~rsc/SDSU/Interpolation.pdf - Similar pages

A simple derivation of Bresenham''s algorithm
A simple derivation of Bresenham''s algorithm. Kenneth H. Carpenter,
EECE KSU. November 4, 1999 / April 4, 2001. Suppose one wishes ...
www.eece.ksu.edu/~khc/classes/636/bresder.html - 6k - Cached - Similar pages

Speeding Up Bresenham''s Algorithm
November/December 1991 (Vol. 11, No. 6). pp.
16-17 Speeding Up Bresenham''s Algorithm. PDF. ...
www.computer.org/cga/cg1991/g6016abs.htm - 9k - 4 Dec 2002 - Cached - Similar pages

681 Development of Bresenham''s Algorithm
681: Development of Bresenham''s Line Drawing Algorithm. Notes: These
code fragments show how optimizing simple line drawing code ...
www.cis.ohio-state.edu/~parent/ classes/681/OLD/Bresenham.html - 6k - Cached - Similar pages

Bresenham''s Algorithm from Both Ends
Performance of Bresenham''s Algorithm drawing simultaneously from
BOTH ends and utilizing the efficiency of a linear framebuffer. ...
www.cs.unc.edu/~hoff/projects/comp235/ bresline/perform2.html - 4k - Cached - Similar pages

Bresenham algorithm
First Previous Index Text. Slide 12 of 12.
mrl.nyu.edu/~dzorin/ug-graphics/ lectures/lecture5/sld012.htm - 3k - Cached - Similar pages

Bresenham modified algorithm - ALL the points
Bresenham modified algorithm which allows to print ALL the points, not only
1 point per axis. ... I suppose you already know the Bresenham''s algorithm. ...
www.ese-metz.fr/~dedu/projects/bresenham/ - 10k - Cached - Similar pages

AcadWiki - Bresenham Algorithm
AcadWiki: HomePage. Bresenham Algorithm. See Digital Line Drawing.
Last edited on 03/14/01. Edit | Info, Valid XHTML 1.0! Valid CSS! ...
xarch.tu-graz.ac.at/autocad/wiki/BresenhamAlgorithm - 9k - Cached - Similar pages



Make it work, then
make it fast.

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
ok, this line thing just isn''t working...

It compiles & runs, but it:

1) This is only drawing every other pixel.

2) I can''t be entirely sure it''s drawing the line EXACTALLY where it''s sopposed to be.

here''s the code:


  int DrawLine(int StartX,	int StartY,			  int EndX,		int EndY, 			  UINT* Buffer,	int Pitch, 			  UINT Color){	int DeltaX = abs(EndX - StartX);	int DeltaY = abs(EndY - StartY);	int x = StartX;	int y = StartY;	int IncX1;	int IncX2;	int IncY1;	int IncY2;	int Numerator;	int Denominator;	int NumAdd;	int NumPixels;		if(EndX >= StartX) // X is increasing.	{		IncX1 = 1;		IncX2 = 2;	}		else			//X is decreasing	{		IncX1 = -1;		IncX2 = -1;	}	if(EndY >= StartY) //Y is increasing	{		IncY1 = 1;		IncY2 = 1;	}	else				//Y is decreasing	{		IncY1 = -1;		IncY2 = -1;	}	if(DeltaX > DeltaY)		//there are more x-values then y-values	{		IncX1 = 0;		IncY2 = 0;		Denominator = DeltaX;		Numerator = DeltaX /2;		NumAdd = DeltaY;		NumPixels = DeltaX;	}	else				//there are more y-values then x-values	{		IncX2 = 0;		IncY1 =	0;		Denominator = DeltaY;		Numerator = DeltaY/2;		NumAdd = DeltaX;		NumPixels = DeltaY;	}	int CurrentPixel;	for(CurrentPixel = 0; CurrentPixel <= NumPixels; CurrentPixel++)	{		PlotPixel32(x,y,Buffer,Color,Pitch);		Numerator += NumAdd;				if(Numerator >= Denominator)		{			Numerator -= Denominator;			x += IncX1;			y += IncY1;		}				x += IncX2;		y += IncY2;	}	return 1;}  
Programmers of the world, UNTIE!

This topic is closed to new replies.

Advertisement