3

更新:

我有一个数据列表图,我想收集与 Mathematica 中的列表图重叠的圆形图形的特定边界内的所有数据点。

这样的事情可能吗?

我制作的椭圆的形式是

{c, s, \[Theta]} = 
 1 /. ComponentMeasurements[f, {"Centroid", "SemiAxes", "Orientation"}]
Show[Rasterize[p], Graphics[{Red, Rotate[Circle[c, s], \[Theta]]}]]

你能帮我把你最底层的解决方案放入一个表格中,我可以在其中输入我的椭圆,包括 Centroid、SemiAxes 和 Orientation 属性吗?

4

1 回答 1

6
data = RandomReal[{0, 1}, {100, 2}]
r = 1/5;
center = {1/6, 1/4};
sd = Select[data, EuclideanDistance[#, center] < r &]
Show[ListPlot@data, 
     Graphics@Circle[center, r], 
     Graphics[{Red, PointSize[Large], Point@sd}], AspectRatio -> 1]

数学图形

编辑

对于椭圆

data = RandomReal[{0, 1}, {100, 2}]
r = 1/5;
f1 = {1/6, 1/4};
f2 = {1/3, 1/5};
sd = Select[data, EuclideanDistance[#, f1] + EuclideanDistance[#, f2] < r &]
Show[ListPlot@data, 
     RegionPlot[EuclideanDistance[{x, y},f1] + EuclideanDistance[{x, y},f2] <r, 
                {x, 0, 1}, {y, 0, 1}], 
     Graphics[{Red, PointSize[Large], Point@sd}], AspectRatio -> 1]

数学图形

编辑 2

更好的代码

data = RandomReal[{0, 1}, {100, 2}]
r = 1/5;
f1 = {1/6, 1/4};
f2 = {1/3, 1/5};
inside[{x_, y_}, {f1_, f2_}] := Sum[EuclideanDistance[{x, y}, i], {i, {f1, f2}}];
sd = Select[data, inside[#, {f1, f2}] < r &];
Show[ListPlot@data,
     RegionPlot[inside[{x, y}, {f1, f2}] < r, {x, 0, 1}, {y, 0, 1}],
     Graphics[{Red, PointSize[Large], Point@sd}],
  AspectRatio -> 1]

编辑 3

在这里,您将整个内容转换为您的ComponentMeasurements输出

(*{c,s,t}=1/.ComponentMeasurements[f,{"Centroid","SemiAxes",\
"Orientation"}] *)
c = {.3, .4}
s = {.4, .2}
t = Pi/8

{s1, s2} = s
center = {cx, cy} = c
f = Sqrt[s1 s1 - s2 s2]
f1 = {f1x, f1y} = {cx + f Cos[t], cy - f Sin[t]}
f2 = {f2x, f2y} = {cx - f Cos[t], cy + f Sin[t]}
r = 2 Sqrt[f f + s2 s2]

data = RandomReal[{0, 1}, {100, 2}];

sd = Select[data, EuclideanDistance[#, f1] + EuclideanDistance[#, f2] < r &];
Show[
 ListPlot@data, 
 RegionPlot[ EuclideanDistance[{x, y}, f1] + EuclideanDistance[{x, y}, f2] < r,
              {x, 0, 1}, {y, 0, 1}], 
 Graphics[{Red, PointSize[Large], Point@sd}], 
AspectRatio -> 1]

数学图形

于 2012-08-02T18:29:11.587 回答