[futurebasic] Re: [FB] recording points in a plotted polygon

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : January 2002 : Group Archive : Group : All Groups

From: tedd <tedd@...>
Date: Tue, 8 Jan 2002 10:21:13 -0500
Hayden:

I know exactly what you need. The polygon statement does just record 
only those vertices from significant x,y point to significant x,y 
point. All points in between are not represented in the structure (a 
polygon is a structure record).

So, what you have to do is to determine what points lie upon each 
line segment generated. You would do this via a formula that for 
every x renders y based upon the orientation (slope) of the line 
segment. This, despite the high number of calculations, is simply a 
geometry problem.

For example if you had a line of 0,0 to 10,10, (i.e.,  MOVETO 
(0,0):LINETO (10,10) ) you would have the points:

1,1 -- 2,2  -- 3,3 -- 4,4 -- 5,5 -- 6,6 -- 7,7 -- 8,8 -- 9,9 -- 10,10

As I said, this is a simple geometry problem, so figure out how to do that.

My question is why do you want to do that?

tedd

>Greetings from Snowy Maine:
>      Robert and Tedd were both kind enough to respond to my query about
>recording points produced in drawing a polygon; they were both most helpful,
>however, I still haven't figured out how to solve (efficiently) my problem.  I
>know the vertices of a polygon that I wish to plot on the screen (it 
>is a closed
>figure - most often a hexagon consisting of straight line segments - vertex to
>vertex to +...).  This can be accomplished easily with the PLOT x,y 
>TO y1,y1 TO
>x2,y2+... and this works fine for me. However, I need to know and record the
>coordinates of each point that is traversed (colored) on the screen during the
>PLOT command.  Robert submitted a nice program that generates an anti-aliased
>line from point x,y to x1,y1 and these can be recorded as they pass 
>through the
>calculation.  But this takes about 100X as much time as simply doing the PLOT
>x,y to x1,y1 etc.and that is just for generating the points/lines not even
>recording them. Tedd has submitted the ingenious use of the OPENPOLY and using
>the points storred in its Handle& - however, when I use this 
>program, the handle
>seems to contain only the vertices of a polygon made by repeated 
>calls to LINETO
>x,y and not the intervening points that I need.  It is not really clear to me
>what information is recorded in the POLYHandle in Tedd's program besides the
>vertices.  A mouse drawn figure contains many points, apparently more than the
>number of obvious vertices, but figures of different size often 
>contain counter
>intuitive numbers of points (a larger figure may contain fewer points than a
>smaller one). My conclusion is that the OPENPOLY is storing points 
>at witch the
>direction changes (vertices).  Certainly it doesn't store each point along the
>perimiter of the polygon which is what I want.
>      I guess my question comes down to: can we break into the code 
>for the PLOT
>x,y to x1,y1... command and retrieve the points that are generated 
>and copy them
>into a waiting array?  Clearly the Plot command "knows" (calculates) the
>intervening points as well as the x,y vertices and inserts their 
>color/position
>into the screen structure and it does so about 100X faster than we 
>can simulate
>with IF statements in FB^3 (Robert's program).  It has been 30 years 
>since I did
>assembler coding, but a factor of 100X in my simulation program would be worth
>some effort.  Any guidance in starting this search will be much appreciated.
>      Thanks,  Hayden
>
>
>
>>  '--------- polygon program - should run "as is" ---
>>  Subject:
>>           Storing/retrieving data in/from a polygon
>>      Date:
>>           Mon, 7 Jan 2002 08:08:48 -0500
>>     From:
>>           tedd <tedd@...>
>>       To:
>>           futurebasic@...
>>
>>
>>
>>  Hi gang:
>>
>>  I was asked recently to show a way to store/retrieve data in/from a
>>  polygon. The following is my example:
>>
>>  ftp://ftp.futurebasic.org/FutureBasic/dropbox/polyArrayExample.sit
>>
>>  Any comments welcomed.
>>
>>  tedd
>>
>>  --
>>  http://sperling.com
>
>--
>To unsubscribe, send ANY message to <futurebasic-unsubscribe@...>


-- 
http://sperling.com