예제 #1
0
파일: Polygon.cs 프로젝트: Omybot/GoBot
        /// <summary>
        /// Transforme le polygone en liste de triangle qui représentent la même surface.
        /// </summary>
        /// <returns>Liste de triangles équivalente au polygone</returns>
        public List <PolygonTriangle> ToTriangles()
        {
            List <PolygonTriangle> triangles = new List <PolygonTriangle>();
            List <RealPoint>       points = new List <RealPoint>(Points);
            RealPoint p1, p2, p3;

            do
            {
                p1 = points[0];
                p2 = points[1];
                p3 = points[2];

                PolygonTriangle triangle = new PolygonTriangle(p1, p2, p3);
                if (this.Contains(triangle.Barycenter))
                {
                    triangles.Add(triangle);
                    points.Add(p1);
                    points.RemoveAt(1);
                    points.RemoveAt(0);
                }
                else
                {
                    points.Add(p1);
                    points.RemoveAt(0);
                }
            } while (points.Count >= 3);

            return(triangles);
        }
예제 #2
0
 public PolygonTriangle(PolygonTriangle other) : base(other)
 {
 }