Graphics Mathematica中的Plot delaunay三角剖分
考虑以下示例() 我现在想为一组点绘制DelaunayTriangulation,但无法使用图形绘制语法 想法Graphics Mathematica中的Plot delaunay三角剖分,graphics,geometry,wolfram-mathematica,Graphics,Geometry,Wolfram Mathematica,考虑以下示例() 我现在想为一组点绘制DelaunayTriangulation,但无法使用图形绘制语法 想法 Graphics[ GraphicsComplex[ pts, { Function[{startPt, finishPts},Line[{startPt, #}] & /@ finishPts] @@@ dtpts, Red, Point@Range[Length@pts] } ] ] 如果你需要真正的多边
Graphics[
GraphicsComplex[
pts,
{
Function[{startPt, finishPts},Line[{startPt, #}] & /@ finishPts] @@@ dtpts,
Red, Point@Range[Length@pts]
}
]
]
如果你需要真正的多边形:
Graphics[
GraphicsComplex[
pts,
{EdgeForm[Black],
Function[{startPt, finishPts},
{FaceForm[RGBColor[RandomReal[], RandomReal[], RandomReal[]]],
Polygon[{startPt, ##}]} & @@@
Transpose[{Drop[finishPts, 1],
Drop[RotateRight@finishPts, 1]
}
]
] @@@ dtpts,
Red, Point@Range[Length@pts]
}
]
]
如果你需要真正的多边形:
Graphics[
GraphicsComplex[
pts,
{EdgeForm[Black],
Function[{startPt, finishPts},
{FaceForm[RGBColor[RandomReal[], RandomReal[], RandomReal[]]],
Polygon[{startPt, ##}]} & @@@
Transpose[{Drop[finishPts, 1],
Drop[RotateRight@finishPts, 1]
}
]
] @@@ dtpts,
Red, Point@Range[Length@pts]
}
]
]
方法一,使用类似Sjoerd的多边形,但不存在凸壳上的点引起的问题:
Graphics[{FaceForm[], EdgeForm[Black],
Polygon[pts[[#]] & /@
DeleteCases[dtpts, {i_, _} /; MemberQ[ConvexHull[pts], i]][[All,
2]]], Red, Point[pts]}]
方法二,使用连接相邻点的线:
edges[pts_, {a_, l_List}] := {pts[[a]], #} & /@ pts[[l]]
Graphics[{Line[edges[pts, #]] & /@ dtpts, Red, Point[pts]}]
这两种方法都会产生重复的基本体(三个多边形或两条线,使用每个点作为起点)
我们可以稍微修改数据,并使用内置的可视化功能:
Graphics[{FaceForm[], EdgeForm[Black],
Cases[Normal[
ListDensityPlot[{##, 0.} & @@@ pts, Mesh -> All]], _Polygon,
Infinity], Red, Point[pts]}, ImageSize -> 175]
方法一,使用类似Sjoerd的多边形,但不存在凸壳上的点引起的问题:
Graphics[{FaceForm[], EdgeForm[Black],
Polygon[pts[[#]] & /@
DeleteCases[dtpts, {i_, _} /; MemberQ[ConvexHull[pts], i]][[All,
2]]], Red, Point[pts]}]
方法二,使用连接相邻点的线:
edges[pts_, {a_, l_List}] := {pts[[a]], #} & /@ pts[[l]]
Graphics[{Line[edges[pts, #]] & /@ dtpts, Red, Point[pts]}]
这两种方法都会产生重复的基本体(三个多边形或两条线,使用每个点作为起点)
我们可以稍微修改数据,并使用内置的可视化功能:
Graphics[{FaceForm[], EdgeForm[Black],
Cases[Normal[
ListDensityPlot[{##, 0.} & @@@ pts, Mesh -> All]], _Polygon,
Infinity], Red, Point[pts]}, ImageSize -> 175]
< /P> < P>我喜欢Sjoerd使用<代码>图形复杂> <代码>,但我看不出中间有巴洛克代码。
这似乎很管用:Needs["ComputationalGeometry`"]
pts = RandomReal[{0, 10}, {60, 2}];
dtpts = DelaunayTriangulation[pts];
线
多边形
< /P> < P>我喜欢Sjoerd使用<代码>图形复杂> <代码>,但我看不出中间有巴洛克代码。
这似乎很管用:Needs["ComputationalGeometry`"]
pts = RandomReal[{0, 10}, {60, 2}];
dtpts = DelaunayTriangulation[pts];
线
多边形
@Sjoerd,再次感谢您!我编辑了我的问题来描述DTPT。对输出的新解释。这是更好的,它仍然不是完美的。按照生成方式,所有多边形都会在三角剖分结果中多次出现。但这是排序和使用并集的问题。@Sjoerd,你知道如何计算边数吗?@500 brett定义了一个边函数。您可以使用它,对边缘点排序,删除重复项,计数。简单。@Sjoerd,再次谢谢你!我编辑了我的问题来描述DTPT。对输出的新解释。这是更好的,它仍然不是完美的。按照生成方式,所有多边形都会在三角剖分结果中多次出现。但这是排序和使用并集的问题。@Sjoerd,你知道如何计算边数吗?@500 brett定义了一个边函数。您可以使用它,对边缘点排序,删除重复项,计数。简单,我15分钟前已经改变了我的解决方案。我有一个多边形的解决方案也准备更新…我已经改变了我的解决方案15分钟前。我有一个多边形解决方案也准备更新。。。