本文整理汇总了C#中Polygon.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# Polygon.RemoveAt方法的具体用法?C# Polygon.RemoveAt怎么用?C# Polygon.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon
的用法示例。
在下文中一共展示了Polygon.RemoveAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: triangulateHelper
/// <summary>
/// Helper function to triangulate.
/// </summary>
/// <param name="poly">Polygon to breakdown</param>
/// <param name="tris">List of triangles</param>
/// <returns>List of triangles</returns>
private List<Polygon> triangulateHelper(Polygon poly, List<Polygon> tris)
{
Polygon p = new Polygon(poly);
if (p.Count <= 3)
{
tris.Add(p);
return tris;
}
else
{
for (int i = 0; i < p.Count; i++)
{
Vector2 v = p[i+2] - p[i];
DEASL.Core.Mathematics.Shapes.LineSegment ls = new DEASL.Core.Mathematics.Shapes.LineSegment(
p[i]+0.00001*v, p[i + 2]-0.00001*v);
if(!p.DoesIntersect(ls) && p.IsInside(ls))
{
tris.Add(new Polygon(new Vector2[] {p[i], p[i+1], p[i+2]}));
p.RemoveAt(i+1);
break;
}
}
return triangulateHelper(p, tris);
}
}
示例2: DecomposePolygon
/// <summary>
/// Decompose polygon into triangles
/// </summary>
/// <param name="polygon"></param>
/// <returns></returns>
public List<Polygon> DecomposePolygon(Polygon polygon)
{
List<Polygon> triangles = new List<Polygon>();
bool foundAll = false;
while (!foundAll)
{
for (int i = 1; i < polygon.Count - 1; i++)
{
if (polygon.Count == 3)
{
triangles.Add(polygon);
foundAll = true;
}
// make a triangle
Polygon thisTriangle = new Polygon();
for (int j = -1; j <= 1; j++)
thisTriangle.Add(polygon[i - j]);
// check if the triangle is an ear. If so, add to the list of triangles
if (IsEar(thisTriangle, polygon))
{
triangles.Add(thisTriangle);
polygon.RemoveAt(i);
continue;
}
}
}
return triangles;
}