Exemple #1
0
        /// <summary>
        /// Determines the position of given point in a standard coordinate system
        /// </summary>
        /// <param name="P">Point to be translated back</param>
        /// <param name="SIN">sin of a counter-wise angle of system rotation</param>
        /// <param name="COS">cos of a counter-wise angle of system rotation</param>
        /// <param name="systemCenter">Center of the system point was tanslated to</param>
        /// <returns>Translated back point</returns>
        public GlPointR2 getTranslatedBackPoint(float SIN, float COS, GlPointR2 systemCenter)
        {
            GlPointR2 TranslatedPoint = new GlPointR2(this);

            TranslatedPoint.moveTo(TranslatedPoint.X * COS - TranslatedPoint.Y * SIN + systemCenter.X, TranslatedPoint.X * SIN + TranslatedPoint.Y * COS + systemCenter.Y);
            return(TranslatedPoint);
        }
Exemple #2
0
        /// <summary>
        /// Determines the position of given point in a rotated and parallel-moved coordinate system
        /// </summary>
        /// <param name="P">Point to be translated</param>
        /// <param name="SIN">sin of a counter-wise angle of system rotation</param>
        /// <param name="COS">cos of a counter-wise angle of system rotation</param>
        /// <param name="systemCenter">Center of the system point is being tanslated to</param>
        /// <returns>Translated point</returns>
        public GlPointR2 getPointTranslatedToRotatedSystem(float SIN, float COS, GlPointR2 systemCenter)
        {
            GlPointR2 TranslatedPoint = new GlPointR2(this);

            TranslatedPoint.moveTo((TranslatedPoint.X - systemCenter.X) * COS + (TranslatedPoint.Y - systemCenter.Y) * SIN, -(TranslatedPoint.X - systemCenter.X) * SIN + (TranslatedPoint.Y - systemCenter.Y) * COS);
            return(TranslatedPoint);
        }
Exemple #3
0
        /////////////INTERSECTION_METHODS//////////////
        ///////////////////////////////////////////////
        ////////////////TANGENT_METHODS////////////////

        public GlLineR2[] getTangentFromPoint(GlPointR2 P)
        {
            if (P == null || P.isNullPoint() || this.isPointInside(P))
            {
                return new GlLineR2[] { }
            }
            ;

            GlOval    IO         = new GlOval(this.RadA, this.RadB, new GlVectorR2(this.RadA, 0.0f), new GlPointR2(0.0f, 0.0f));
            GlPointR2 MovedPoint = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, new GlPointR2(this.CenterX, this.CenterY));

            if (this.RadA > this.RadB)
            {
                IO = new GlOval(this.RadB, this.RadA, this.directVector.getRotatedVector((float)Math.PI / 2), new GlPointR2(0.0f, 0.0f));

                MovedPoint.moveTo(MovedPoint.Y, -MovedPoint.X);
            }

            float Devider  = (float)(Math.Pow(IO.RadA * MovedPoint.Y, 2.0) + Math.Pow(IO.RadB * MovedPoint.X, 2.0));
            float fPartRes = (float)Math.Pow(IO.RadA, 3.0) * IO.RadB * MovedPoint.X;
            float sPartRes = IO.RadA * IO.RadA * MovedPoint.Y * (float)Math.Sqrt(Math.Abs(-Math.Pow(IO.RadA, 4.0) + Math.Pow(IO.RadA * MovedPoint.Y, 2.0) + Math.Pow(IO.RadB * MovedPoint.X, 2.0)));

            float xI1 = (fPartRes + sPartRes) / Devider;
            float xI2 = (fPartRes - sPartRes) / Devider;

            float yI1 = (MovedPoint.X < 0 ? 1 : -1) * IO.RadB * (float)Math.Sqrt(Math.Abs(IO.RadA * IO.RadA - xI1 * xI1)) / IO.RadA;
            float yI2 = (MovedPoint.X < 0 ? -1 : 1) * IO.RadB * (float)Math.Sqrt(Math.Abs(IO.RadA * IO.RadA - xI2 * xI2)) / IO.RadA;

            if (Math.Abs(MovedPoint.X) < IO.RadA)
            {
                yI1 = (MovedPoint.Y < 0 && yI1 >= 0) ? -Math.Abs(yI1) : ((MovedPoint.Y > 0 && yI1 < 0) ? Math.Abs(yI1) : yI1);
                yI2 = (MovedPoint.Y < 0 && yI2 >= 0) ? -Math.Abs(yI2) : ((MovedPoint.Y > 0 && yI2 < 0) ? Math.Abs(yI2) : yI2);
            }

            if (this.RadA > this.RadB)
            {
                float temp = xI1;
                xI1 = -yI1;
                yI1 = temp;

                temp = xI2;
                xI2  = -yI2;
                yI2  = temp;
            }

            GlPointR2 P1 = new GlPointR2(xI1, yI1).getTranslatedBackPoint(this.SIN, this.COS, new GlPointR2(this.CenterX, this.CenterY));
            GlPointR2 P2 = new GlPointR2(xI2, yI2).getTranslatedBackPoint(this.SIN, this.COS, new GlPointR2(this.CenterX, this.CenterY));

            return(new GlLineR2[] {
                new GlLineR2(P1, new GlVectorR2(P1.X - P.X, P1.Y - P.Y)),
                new GlLineR2(P2, new GlVectorR2(P2.X - P.X, P2.Y - P.Y))
            });
        }
Exemple #4
0
        public override GlFigure getScaled(float scale)
        {
            GlPointR2 C = new GlPointR2(this.Center);

            C.moveTo(C.X * scale, C.Y * scale);

            GlPolygon PR = new GlPolygon(C);

            for (int i = 0; i < this.CountOfPoints; i++)
            {
                GlPointR2 P = this[i];
                P.moveTo(P.X * scale, P.Y * scale);
                PR.AddVertex(new GlPointR2(P));
            }

            PR.moveTo(this.Center.X, this.Center.Y);
            return(PR);
        }