本文整理汇总了C#中Vertices.GetArea方法的典型用法代码示例。如果您正苦于以下问题:C# Vertices.GetArea方法的具体用法?C# Vertices.GetArea怎么用?C# Vertices.GetArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices.GetArea方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SanityCheck
private static bool SanityCheck(Vertices vertices)
{
if (vertices.Count < 3)
return false;
if (vertices.GetArea() < 0.00001f)
return false;
for (int i = 0; i < vertices.Count; ++i)
{
int i1 = i;
int i2 = i + 1 < vertices.Count ? i + 1 : 0;
Vector2 edge = vertices[i2] - vertices[i1];
if (edge.LengthSquared() < Settings.Epsilon * Settings.Epsilon)
return false;
}
for (int i = 0; i < vertices.Count; ++i)
{
int i1 = i;
int i2 = i + 1 < vertices.Count ? i + 1 : 0;
Vector2 edge = vertices[i2] - vertices[i1];
for (int j = 0; j < vertices.Count; ++j)
{
// Don't check vertices on the current edge.
if (j == i1 || j == i2)
{
continue;
}
Vector2 r = vertices[j] - vertices[i1];
// Your polygon is non-convex (it has an indentation) or
// has colinear edges.
float s = edge.X * r.Y - edge.Y * r.X;
if (s < 0.0f)
return false;
}
}
return true;
}
示例2: SanityCheck
private static bool SanityCheck(Vertices vertices)
{
//Make sure it is is a polygon
if (vertices.Count < 3)
return false;
//Make sure it has a large enugh area
if (vertices.GetArea() < 0.00001f)
return false;
//Make sure no vertices are too close to each other
for (int i = 0; i < vertices.Count; ++i)
{
Vector2 current = vertices[i];
Vector2 next = vertices.NextVertex(i);
Vector2 edge = next - current;
if (edge.LengthSquared() < Settings.Epsilon * Settings.Epsilon)
return false;
}
return true;
}