I have a set of random numbers distributed on a annular disk. I want to find points on the inner and outer edge along a particular angle.
One possibility is to use ConvexHull
. For example
n = 1000;
pts = {#[[1]] Cos[#[[2]]], #[[1]] Sin[#[[2]]]} & /@
Transpose[{RandomReal[{4, 6}, n], RandomReal[{0, 2 Pi}, n]}];
q = -3 Pi/4; (*Direction*)
dq = Pi/10; (*Span*)
Needs["ComputationalGeometry`"]
dq0=0.01; (*use slightly bigger angle to select*)
pts4=Select[pts, q-dq-dq0 < ArcTan@@# < q+dq+dq0 &];
out=pts4[[ConvexHull[pts4]]];
R=Mean[Norm/@pts4];
edge1=Select[out, q-dq < ArcTan@@# < q+dq && Norm[#] < R &];
edge2=Select[out, q-dq < ArcTan@@# < q+dq && Norm[#] > R &];
Grid[{{
Graphics[{LightBlue,Disk[{0,0},6,{q-dq,q+dq}],
PointSize[Large],Orange, Point[pts4], PointSize[Small], Black,
Point[pts], Dashed, Red, Circle[{0,0},4], Circle[{0,0},6]},
ImageSize->300],
Graphics[{LightBlue,Disk[{0,0},6,{q-dq,q+dq}],
PointSize[Large], Green, Point[edge1], Blue, Point[edge2],
PointSize[Small], Black, Point[pts], Dashed,
Red, Circle[{0,0},4], Circle[{0,0},6]},
ImageSize->300]
}}]
But it doesn't cover all edge points.
Another way
Another possibility is, as suggested by Batracos, is to use the radial distance as filtering condition. Since the points are not uniformly distributed, there may or may not be a point within a radial range along a particular direction. As you can see from the figure that the inner edge is much deeper in the middle of the blue region than the border.
Clarification : "Point at the edge"
By point at the edge I mean the points which construct the boundary. For example consider this segment
I need to find points constructing the blue and red lines. ConvexHull
gives only points on the green line, which is very small in number. I would prefer a tunable parameter which can determine the roughness of the edges (which is the slice width here). Increasing the roughness/slice width will include more points in this case.
Here I used the the slicing to find the edges
dat = {RandomReal[{-10, 10}], RandomReal[{-2, 2}]} & /@ Range[500];
Needs["ComputationalGeometry`"]
pts1 = dat[[ConvexHull[dat]]];
dqq = 0.5;(*slice width*)
slice = Most@Range[-10, 10, dqq];
edge1 = edge2 = {};
Do[ps = Sort[
Select[dat, qq < #[[1]] < qq + dqq &], #1[[2]] < #2[[2]] &];
If[Length[ps] > 0, AppendTo[edge1, First[ps]];
AppendTo[edge2, Last[ps]];]
,{qq, slice}]
Graphics[{PointSize[Large], Blue, Line[edge1], Red, Line[edge2],
Green, Dashed, Line[pts1], PointSize[Small], Black, Point[dat]},
ImageSize -> 300]
distances = Norm /@ pts; mindistance = Min[distances]; d = .001; in = Pick[pts, Abs[Norm[#] - mindistance] <= d & /@ distances]
? $\endgroup$d
, you may or may not have a point, because the inner edge is not at same depth everywhere - just look at the middle and border of the shaded region. Your suggestion will fit nicely for uniform points, but for random case - I am not sure. I am editing the question based on your suggestion. $\endgroup$