[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*Subject*: Re: pixel coordinates of a line*From*: Struan Gray <struan.gray(at)sljus.lu.se>*Date*: 2 Jul 2001 10:47:06 GMT*Distribution*: world*Newsgroups*: comp.lang.idl-pvwave*Organization*: This line intentionally left bland*References*: <3B3ACEBC.B64C9408@hotmail.com> <MPG.15a6363025fdb692989e19@news.frii.com> <3B3C401B.904C5F01@hotmail.com> <on7kxvbeup.fsf@cow.physics.wisc.edu>*Xref*: news.doit.wisc.edu comp.lang.idl-pvwave:25492

A blast from the past. I'm old enough to have had to write my own graphical user interface from scratch. I did so on a curious HP Pascal Workstation, which had a graphics library based on HPGL, but the plotting was *one* *hundred* times slower than if you just stuffed pixels into the display memory yourself. Anyway, my algorithm for drawing a line was this: First clip the line (if necessary) using geometry-derived algebra like Tom's, this gives you (x1,y1) and (x2,y2), the screen coordinates of the line that will actually be drawn. Then find out which of (x2-x1) and (y2-y1) had the largest magnitude, this gives you the number of pixels, since there will be one pixel for each integer value of this coordinate. Finally, loop through the coordinates for whichever axis had the longest span, adding the index times the line's slope to the other coordinate. Using integer maths made the rounding off automatic and fast. In IDL you could do this step as a matrix operation with an index matrix. Struan

**References**:**pixel coordinates of a line***From:*Marc Schellens

**Re: pixel coordinates of a line***From:*David Fanning

**Re: pixel coordinates of a line***From:*Marc Schellens

**Re: pixel coordinates of a line***From:*Craig Markwardt

- Prev by Date:
**Re: VARRAY, memory & extracting subarrays** - Next by Date:
**Re: Intersecting geometric shapes** - Prev by thread:
**Re: pixel coordinates of a line** - Next by thread:
**IDL and 'nice' question** - Index(es):