Re: Efficient way to search for overlapping circles of varying radii?
- From: Hans-Bernhard Broeker <broeker@xxxxxxxxxxxxxxxxxxxxx>
- Date: 5 Jun 2006 09:29:22 GMT
Jonathan Greenberg <usenet@xxxxxxxxxxxxx> wrote:
I apologize in advance if this is a fairly elementary problem -- I'm an
ecologist, not a computer scientist so I've no background in geometric
searching. I have the following problem that I'd like to code up, and my
first attempt is as slow as it goes:
Given a set of x,y,r which represent points at coordinates x,y and a radius
r, I want to output a new set of x,y,r such that (given two points
p1={x1,y1,r1} and p2={x2,y2,r2}):
If the distance between p1 and p2 is less than the radius of p2 AND the
radius of p1 is less than the radius of p2, remove p1. In practice, this
means that I want to remove all circles whose center is within the area of a
LARGER circle, as long as that larger circle has not already been removed.
That's a somewhat strange way of stating a problem. Instead of
defining what you want as the result, you state an incomplete
algorithm for getting there. That's putting the horse before the
carriage.
For all we can know your existing algorithm, while catastrophically
inefficient, may be needed to fulfil some extra expectation you have
about the result, but failed to state here.
Generally said sorting by radius is quite unlikely to help you here.
You'll have to split up the problem into geometrically smaller
regions, i.e. divide and conquer. Get an algorithms textbook if you
don't have one yet, and look up k-d trees and related algorithms for
sorting and searching in datasets of more than 1 dimension.
--
Hans-Bernhard Broeker (broeker@xxxxxxxxxxxxxxxxxxxxx)
Even if all the snow were burnt, ashes would remain.
.
- Follow-Ups:
- Re: Efficient way to search for overlapping circles of varying radii?
- From: Jonathan Greenberg
- Re: Efficient way to search for overlapping circles of varying radii?
- References:
- Efficient way to search for overlapping circles of varying radii?
- From: Jonathan Greenberg
- Efficient way to search for overlapping circles of varying radii?
- Prev by Date: Re: Collisions & landscapes
- Next by Date: Automatic layout. Algorithm
- Previous by thread: Re: Efficient way to search for overlapping circles of varying radii?
- Next by thread: Re: Efficient way to search for overlapping circles of varying radii?
- Index(es):
Relevant Pages
|