Beispiel #1
0
        public IEnumerable <int> GetVertices(PolygonDirection direction)
        {
            yield return(A);

            yield return(B);

            yield return(C);
        }
Beispiel #2
0
        public void SetConvex(Vertex prev, Vertex next, PolygonDirection direction)
        {
            var a = Position - prev.Position;
            var b = next.Position - Position;

            var sign = (int)Mathf.Sign(a.x * b.y - a.y * b.x);

            IsConvex = sign >= 0 ^ direction == PolygonDirection.ClockWise;
        }
        public static PolygonDirection TriangleArea2(Vector2 p1, Vector2 p2, Vector2 p3, ref float area)
        {
            GeoPointsArray2 array = new GeoPointsArray2();

            array.mPointArray.Add(p1);
            array.mPointArray.Add(p2);
            array.mPointArray.Add(p3);
            PolygonDirection dir = GeoPolygonUtils.CalculatePolygonArea(array, ref area);

            area = area < 0 ? -area : area;
            return(dir);
        }
Beispiel #4
0
        public void Initialize()
        {
            float area = 0.0f;

            mDirection = GeoPolygonUtils.CalculatePolygonArea(mPolygon, ref area);
            if (mDirection == PolygonDirection.CW)
            {
                Reverse();
                mDirection = PolygonDirection.CCW;
            }
            else
            {
                area = -area;
                InitializeArray();
            }
        }
Beispiel #5
0
 public static int[] Triangulate(IEnumerable <Vector3> points, PolygonDirection direction) => Triangulate(points.Select(p => p.XZ()), direction);
Beispiel #6
0
 private Triangulator(IEnumerable <Vector2> points, PolygonDirection direction)
 {
     Vertices  = new LinkedList <Vertex>(points.Select((p, i) => new Vertex(p, i)));
     Direction = direction;
 }
Beispiel #7
0
        public static int[] Triangulate(IEnumerable <Vector2> points, PolygonDirection direction)
        {
            var triangulator = new Triangulator(points, direction);

            return(triangulator.Triangulate());
        }