Points in a circular area

Jim Hurley jhurley at infostations.com
Thu Jan 29 20:16:48 EST 2004


>
>Message: 2
>Date: Thu, 29 Jan 2004 15:26:38 -0800 (PST)
>From: Alejandro Tejada <capellan2000 at yahoo.com>
>Subject: Re: Points in a circular area
>To: use-revolution at lists.runrev.com
>Message-ID: <20040129232638.87440.qmail at web40504.mail.yahoo.com>
>Content-Type: text/plain; charset=us-ascii
>
>on Thu, 29 Jan 2004
>Dar Scott wrote:
>
>>  Some years ago I designed a model and library for
>>  working with abstractions of drawings and
>>  paintings in a functional (that is f()
>>  manner) way.
>>
>>  In that model the plane could be partitioned by a
>>  line or by a circle and other shapes. 
>>  A pie shape is the union (ANDing) of two line
>>  partitions and a circle partition.
>
>>  For this particular case, it might be easier for you
>>  to arctan2 points relative to the center to see
>>  if they are in the right angle range and
>>  then check the distance to see if that is small
>>  enough.
>
>If i interpret right your recommendations,
>it's similar to the procedure that Jim Hurley
>is suggesting to use. Now, i'll code a solution
>and post the script for speed enhancements. ;-)
>
>>  In rendering (or creating point lists) I am trying
>>  to use interval arithmetic and am putting that off
>>  until some performance changes in Revolution. 
>>  This method allows tests to work on
>>  whole zones of pixels in one calculation.
>
>This sounds useful. Could externals helps for
>these tasks?
>
>>  The line tests will be faster than the arctan2
>>  tests for this method, because of the ignorance
>>  involved in interval arithmetic. 
>
>I've read that assembler code is faster than c code.
>
>>  In the mean time you might try testing each pixel (I
>>  assume you mean pixels) in the bounding rect
>>  of the circle of which the arc is part.
>
>Let's see how much time does this calculation takes.


Al,

Just for an estimate of the time needed for the trial and error 
method, I ran the following handler:


on mouseUp
   put 30 into tAngle
   put 100 into R
   put "" into results
   put the sec into startTime
   startTurtle
   repeat with x = 0 to R
     repeat with y = 0 to R
       put raCor(x,y) into ra
       --Test to see if the point x,y is in the wedge.
       if item 1 of ra < R and item 2 of ra < tAngle then put x,y & 
return after results
     end repeat
   end repeat
   put results into field 1
   put the sec - starttime
   beep
end mouseUp

It determines all integer coordinates inside a circular wedge of 
radius R (100) and arc tAngle (30 degrees). There are 2,666 points 
and it takes a little over a second to compute.

(The function raCor(x,y) returns the radial coordinates (radius and 
angle) corresponding to the rectangular coordinates x,y.)

Hope this gives you some idea on times.

Jim



More information about the use-livecode mailing list