Gene Heskett wrote:
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 robotics.

That may be true for some applications, but somehow I doubt
that a sonar beam 30 degrees wide would be able to locate
an object with arc-second accuracy.

We should be asking the OP, though. How coarse is the grid?
What kind of angular resolution is needed?

If the grid isn't too fine, I'd suggest doing something very
simple: Iterate over all the cells in the bounding rectangle
of the arc, and test whether each one is inside it.

There are two parts to that: is it inside the circle, and
is it between the two bounding lines?

Both of these can be answered with some straightforward
arithmetic. It's inside the circle if x*x + y*y <= r*r,
and a couple of vector dot products will answer the other
one. You can probably find a way to do all that in
parallel using numpy.

That leaves finding the slopes of the bounding lines.
Using trig is probably fast enough for that -- it's only
a couple of trig calls for the whole thing, which in
Python will be totally swamped by all the other calculations
you're doing. Or if you really want to avoid trig, use
a lookup table.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to