Here I have a list of points on the plane:
lst = RandomReal[{-5, 5}, {55, 2}];
and a disk with the radius r=1
drawn around the point number i. i will be taken equal 5 in this example below.
I want to select all points with the distance to the disk larger than r
. Here I am doing it:
Clear[lst2, lst3, i, r];
i = 5;
r = 1;
(* This makes a list with a dropped i-th element *)
lstA = lst /. x_ /; x == lst[[i]] -> Nothing;
(* This selects a sublist from the lstA that fulfills the requirement *)
lst1 = Select[lstA, RegionDistance[Disk[lst[[i]], 1], #] >= 2 r &];
For the visual purpose here is a list of points that are closer than 1 to the disk:
lst2 = Select[lstA, RegionDistance[Disk[lst[[i]], 1], #] < 2 r &];
Now let us draw this, showing the points that must be closer in red, and those far - in black:
Graphics[{Blue, Opacity[0.3], Disk[lst[[i]], 1], Opacity[1], Black,
Point[#] & /@ lst1, Red, Point[#] & /@ lst2}]
We see something quite unexpected. Some red points are outside it, though must be inside. Do I strongly miss something?
r
. From the docs ofRegionDistance
: "Region distance is effectively given byMinValue[{Norm[p-q],q\[Element]reg},q]
." $\endgroup$