Exemplo n.º 1
0
        private static bool IsEar(List <Vector2> points, int a, int b, int c)
        {
            // See if the angle ABC is concave.
            if (GetAngle(points[a].X, points[a].Y, points[b].X, points[b].Y, points[c].X, points[c].Y) > 0)
            {
                // This is a concave corner so the triangle
                // cannot be an ear.
                return(false);
            }

            // Make the triangle A, B, C.
            PolygonTriangle triangle = new PolygonTriangle(points[a], points[b], points[c]);

            // Check the other points to see
            // if they lie in triangle A, B, C.
            for (int i = 0; i < points.Count; i++)
            {
                if ((i != a) && (i != b) && (i != c))
                {
                    if (triangle.Contains(points[i]))
                    {
                        // This point is in the triangle
                        // do this is not an ear.
                        return(false);
                    }
                }
            }

            // This is an ear.
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets specified copy of triangle of polygon
        /// </summary>
        /// <param name="index">Index of triangle</param>
        /// <returns>Copy of triangle</returns>
        public PolygonTriangle GetTriangle(int index)
        {
            PolygonTriangle orgTri = m_triangles[index];
            PolygonTriangle copy   = new PolygonTriangle(orgTri.A, orgTri.B, orgTri.C);

            copy.m_position = m_position;
            copy.m_origin   = m_origin;
            copy.m_rotation = m_rotation;
            return(copy);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="polygonTriangle">Polygon triangle</param>
 protected PolygonTriangle(PolygonTriangle polygonTriangle)
     : base(polygonTriangle)
 {
 }