gpt4 book ai didi

wolfram-mathematica - 我如何从 Mathematica 中椭圆图形内的列表图中收集数据点?

转载 作者:行者123 更新时间:2023-12-01 23:24:51 28 4
gpt4 key购买 nike

更新:

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

这样的事情可能吗?

我做的椭圆是这样的

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

你能帮我把你最底层的解决方案放到一个表单中吗?我可以在其中输入具有质心、半轴和方向属性的椭圆?

最佳答案

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]

Mathematica graphics

编辑

对于椭圆

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]

Mathematica graphics

编辑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]

Mathematica graphics

关于wolfram-mathematica - 我如何从 Mathematica 中椭圆图形内的列表图中收集数据点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11783394/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com