Xiaolin Wu's line algorithm: Difference between revisions

Content deleted Content added
correct variables v1,v2 which should be y1,y2, and fix indentation to use tabs consistently
Line 1:
'''Xiaolin Wu's line algorithm''' is an [[algorithm]] for line [[antialiasing]], which was presented in the article ''An Efficient Antialiasing Technique'' in the [[July]] [[1991]] issue of ''[[Computer Graphics]]'', as well as in the article ''Fast Antialiasing'' in the [[June]] [[1992]] issue of ''[[Dr. Dobb's Journal]]''.
 
[[Bresenham's line algorithm|Bresenham's algorithm]] draws lines extremely quickly, but it cannot perform anti-aliasing. In addition, it cannot handle the case where the line endpoints do not lie exactly on integer points of the pixel grid. A naïvenaïve approach to anti-aliasing the line would take an extremely long time, but Wu's algorithm is quite fast (It is still slower than Bresenham's, though). The basis of the algorithm is to draw pairs of pixels straddling the line, coloured according to proximity. Pixels at the line ends are handled separately. Lines less than one pixel long should be handled as a special case.
 
Here is [[pseudocode]] for the nearly-horizontal case (<math>\Delta x > \Delta y</math>). To extend the algorithm to work for all lines, swap the x and y coordinates when near-vertical lines appear (for reference, see [[Bresenham's line algorithm]]).
Line 55:
 
==References==
* {{cite journal
* {{Journal reference| Author=Abrash, Michael | Title=[http://www.gamedev.net/reference/articles/article382.asp Fast Antialiasing] (Column). | Journal=[[Dr. Dobb's Journal]] | Year=June 1992 | Volume=17 | Issue=6 | Pages=139(7)}}
| author=Abrash, Michael
* {{Journal reference| Author=Wu, Xiaolin | Title=[http://portal.acm.org/citation.cfm?id=122734 An efficient antialiasing technique] | Journal=[[Computer Graphics]] | Year=July 1991 | Volume=25 | Issue=4 | Pages=143&ndash;152}} ISBN 0-89791-436-8.
| url = http://www.gamedev.net/reference/articles/article382.asp
* Wu, Xiaolin (1991). Fast Anti-Aliased Circle Generation. In James Arvo (Ed.), ''Graphics Gems II''. pp. 446&ndash;?. San Francisco: Morgan Kaufmann. ISBN 0-12-064480-0.
| title = Fast Antialiasing (Column)
| journal=[[Dr. Dobb's Journal]]
| year=June 1992 | volume=17 | issue=6 | pages=139(7)
}}
* {{cite journal
| author=Wu, Xiaolin
| url = http://portal.acm.org/citation.cfm?id=122734
| title = An efficient antialiasing technique
| journal=[[Computer Graphics]]
| year=July 1991 | volume=25 | issue=4 | pages=143–152
| id = ISBN 0-89791-436-8
}}
* {{Book reference
| Author = Wu, Xiaolin
| Year = 1991
| Chapter = Fast Anti-Aliased Circle Generation
| Editor = James Arvo (Ed.)
| Title = Graphics Gems II
| Pages = pp. 446–?
| Location = San Francisco
| Publisher = Morgan Kaufmann
| ID = ISBN 0-12-064480-0
}}
 
==External links==