calculate part of solid circle in 2D array

Gene Heskett gheskett at
Mon Nov 25 16:53:31 CET 2013

On Monday 25 November 2013 10:18:29 Roy Smith did opine:

> In article <1fc9a269-4847-4d29-a35e-5cf91731e295 at>,
>  Robert Voigtlنnder <r.voigtlaender at> wrote:
> > Thanks a lot for the links.
> > 
> > I don't need it to be drawn. I need the fields within the arc for some
> > statistical calculations for an occupancy map.
> > So the target is a 2D array, not a picture.
> > 
> > Robert
> If you go with one of the suggestions to use a graphics package to draw
> the arc, you can then take the resulting bitmap image and iterate over
> it to see which pixels are black and which are white.
> But, I'm wondering about your comment that, "Using trigonometry is too
> expensive".  Trig is cheaper than you think, because it's all done down
> in the C libraries, and I wouldn't be surprised if it's not pushed all
> the way down to the hardware on most modern machines.  Compared to your
> Python application code, I suspect the amount of trig needed for this
> problem isn't going to be a major factor in timing.
> Are you guessing that trig is too slow, or have you actually done some
> profiling to measure whether it is or not?
> What's the resolution required?  Let's assume a 1k x 1k image with the
> sensor in the center and you need 1 degree angular resolution.  There's
> about 2200 pixels in each 1-degree sector.  You could pre-compute those
> and store 360 sets of 2200 pixels each (about 800k points total).  For
> any given 30 degree sector, just "or" together the 30 1-degree slices
> and you've got your set of pixels for that sector.
> Will it be fast enough?  Beats me, but it's easy to test.

A side comment here if I may.  Your 1 degree assumption is, generally 
speaking, an extremely coarse answer in terms of the accuracy needed, as we 
need accuracies a lot closer to an arc-second than to a whole degree in 

To get an idea, assume a pick-n-place arm that has to retrieve the part 
from whatever method delivers it to within reach of the arm, the arms total 
joint to joint to joint length is 4 feet, and that the part is being 
delivered hot as in 700F, while the piece it will be installed on is fresh 
from contact with a block of dry ice.  So its a shrink fit, a one time 
assembly because once the temps equalize, the part will be shrunk into 
place so tightly that it can only be removed by a lathe.

So the accuracy needed to place this part properly at the start of the push 
to set it in place is .01mm, and the push into position must be done to a 
.01mm accuracy before the parts freeze together.

I know, this is a bit like asking if that persimmon branch will hold 2 
opossums, but what is the accuracy needed in arc seconds per joint 
(counting the arms pivot joint, and an articulated wrist for part 
orientation, makes at least 5 joints, to pull this motion off every 15 
seconds on some GM part assembly line at Delphi?

Real world problem guys.  My own experience with machine vision says that 
without cameras and video processing running at 1000x the speeds of what I 
can buy on fleabay, its way to slow (see camview-emc for an example) to 
actually be used in a production line environment, they don't have time for 
the arm to stop just short of where its going, take a closeup pix & wait 
3-5 seconds for the video to be processed, and then apply the corrective 
moves to 'get it right'.

This isn't even worth a reply, its even off-topic, but when an OP posits a 
problem, he should posit it in terms of his real world targets, as should 
the answers proposed.  The correct answer may well help your parent company 
sell Delphi some new machines at 5 mil/copy.

Cheers, Gene
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

Wedding is destiny, and hanging likewise.
		-- John Heywood
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
         law-abiding citizens.

More information about the Python-list mailing list