当前位置: 首页>>代码示例>>C#>>正文


C# Vertices.GetArea方法代码示例

本文整理汇总了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;
        }
开发者ID:vvnurmi,项目名称:assaultwing,代码行数:44,代码来源:CuttingTools.cs

示例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;
        }
开发者ID:shadowmint,项目名称:pongstar,代码行数:23,代码来源:CuttingTools.cs


注:本文中的Vertices.GetArea方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。