Exemple #1
0
        ////////////////DRAW_METHODS///////////////////
        ///////////////////////////////////////////////
        /////////////INSIDE_BELONGS_METHODS////////////

        public bool isPointInside(GlPointR2 P)
        {
            float SP = 0;

            for (int i = 0; i < this.CountOfPoints - 1; i++)
            {
                SP += new GlTriangle(P, this.vertexes[i], this.vertexes[i + 1]).S;
            }
            SP += new GlTriangle(P, this.vertexes[this.CountOfPoints - 1], this.vertexes[0]).S;

            return(Math.Abs(SP - S) < FAULT);
        }
Exemple #2
0
        ///////////////////////////////////////////////
        ////////////////////FIELDS/////////////////////
        ///////////////////////////////////////////////


        /*********************************************/


        ///////////////////////////////////////////////
        /////////////////CONSTRUCTORS//////////////////
        ///////////////////////////////////////////////

        public GlPolygon(GlPointR2 Center, params GlPointR2[] POLY)
        {
            S = 0;

            if (POLY == null || Center == null)
            {
                polyCenter = new GlPointR2(float.NaN, float.NaN);
                vertexes   = new GlPointR2[0];

                return;
            }

            if (POLY.Length > 3)
            {
                GlPointR2 P = new GlPointR2((POLY[0].X + POLY[POLY.Length / 2].X) / 2, (POLY[0].Y + POLY[POLY.Length / 2].Y) / 2);
                for (int i = 0; i < POLY.Length - 1; i++)
                {
                    S += new GlTriangle(P, POLY[i], POLY[i + 1]).S;
                }
                S += new GlTriangle(P, POLY[POLY.Length - 1], POLY[0]).S;
            }

            this.polyCenter = Center;

            this.vertexes = new GlPointR2[POLY.Length];
            Array.Copy(POLY, this.vertexes, this.vertexes.Length);

            if (this.vertexes.Length == 0)
            {
                return;
            }

            for (int i = 0; i < this.vertexes.Length - 1; i++)
            {
                P += new GlVectorR2(this.vertexes[i + 1].X - this.vertexes[i].X, this.vertexes[i + 1].Y - this.vertexes[i].Y).Length;
            }
            P += new GlVectorR2(this.vertexes[0].X - this.vertexes[this.vertexes.Length - 1].X, this.vertexes[0].Y - this.vertexes[this.vertexes.Length - 1].Y).Length;
        }
Exemple #3
0
 public GlTriangle(GlTriangle copyTiangle) :
     this(copyTiangle == null ? new GlPointR2(float.NaN, float.NaN) : copyTiangle[0],
          copyTiangle == null ? new GlPointR2(float.NaN, float.NaN) : copyTiangle[1],
          copyTiangle == null ? new GlPointR2(float.NaN, float.NaN) : copyTiangle[2])
 {
 }