Exemple #1
0
        ////////////////TANGENT_METHODS////////////////
        ///////////////////////////////////////////////
        /////////////INSIDE_BELONGS_METHODS////////////

        public override bool isPointInside(GlPointR2 P)
        {
            if (P == null || P.isNullPoint())
            {
                return(false);
            }

            GlPointR2 TP = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Center);

            return(Math.Pow(TP.X / RealHalfAixis, 2.0) - Math.Pow(TP.Y / AdditionalHalfAixis, 2.0) - 1 > -FAULT);
        }
Exemple #2
0
        public override bool isPointBelongs(GlPointR2 P)
        {
            if (P == null || P.isNullPoint())
            {
                return(false);
            }

            GlPointR2 TP = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Center);

            return(Math.Abs(TP.X - RealHalfAixis * Math.Sqrt(TP.Y * TP.Y + Math.Pow(AdditionalHalfAixis, 2.0)) / AdditionalHalfAixis) < FAULT);
        }
Exemple #3
0
        public override bool isPointBelongs(GlPointR2 P)
        {
            if (P == null || P.isNullPoint())
            {
                return(false);
            }

            GlPointR2 LineMovedPoint = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, new GlPointR2(this.CenterX, this.CenterY));

            return(Math.Abs(Math.Pow(LineMovedPoint.X / this.RadA, 2.0) + Math.Pow(LineMovedPoint.Y / this.RadB, 2.0) - 1) < FAULT);
        }
Exemple #4
0
        public override bool isPointBelongs(GlPointR2 P)
        {
            if (P == null || P.isNullPoint())
            {
                return(false);
            }

            GlPointR2  RP  = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Vertex);
            GlParabola RPB = new GlParabola(this.A, new GlPointR2(0, 0), new GlVectorR2(1, 0));

            return(Math.Abs(RP.Y - RPB.A * RP.X * RP.X - RPB.B * RP.X - RPB.C) < FAULT);
        }
Exemple #5
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 #6
0
        /////////////INTERSECTION_METHODS//////////////
        ///////////////////////////////////////////////
        ////////////////TANGENT_METHODS////////////////

        public override GlLineR2 getTangentFromBelongs(GlPointR2 P)
        {
            if (P == null || !this.isPointBelongs(P))
            {
                return(new GlLineR2(new GlPointR2(null), new GlVectorR2(null)));
            }

            GlPointR2 TP = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Center);
            float     k  = (TP.Y >= 0 ? 1 : -1) * AdditionalHalfAixis * TP.X / (RealHalfAixis * (float)Math.Sqrt(TP.X * TP.X - Math.Pow(RealHalfAixis, 2.0)));

            GlLineR2 tangent = new GlLineR2(P, new GlVectorR2(1, 0).getRotatedVector((float)Math.Atan(k)));

            tangent.Rotate(this.SIN, this.COS);
            return(tangent);
        }
Exemple #7
0
        /////////////INTERSECTION_METHODS//////////////
        ///////////////////////////////////////////////
        ////////////////TANGENT_METHODS////////////////

        public override GlLineR2 getTangentFromBelongs(GlPointR2 P)
        {
            if (P == null || P.isNullPoint())
            {
                return(new GlLineR2(new GlPointR2(null), new GlVectorR2(null)));
            }

            GlParabola TPB = new GlParabola(this.A, new GlPointR2(0, 0), new GlVectorR2(1, 0));
            GlPointR2  TP  = P.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Vertex);

            float k = 2 * TPB.A * TP.X + TPB.B;

            GlLineR2 tangent = new GlLineR2(P, new GlVectorR2(1, 0).getRotatedVector((float)Math.Atan(k)));

            tangent.Rotate(this.SIN, this.COS);
            return(tangent);
        }
Exemple #8
0
        public override GlLineR2 getTangentFromBelongs(GlPointR2 P)
        {
            if (P == null || P.isNullPoint() || !this.isPointBelongs(P) || this.RadA == 0.0f)
            {
                return(new GlLineR2(new GlPointR2(null), new GlVectorR2(null)));
            }

            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));

            GlLineR2 tangent = new GlLineR2(MovedPoint, new GlVectorR2(-(float)Math.Pow(this.RadA, 2.0) * MovedPoint.Y, (float)Math.Pow(this.RadB, 2.0) * MovedPoint.X));

            tangent.Rotate(this.SIN, this.COS);
            tangent.moveTo(P);

            return(tangent);
        }
Exemple #9
0
        /// <returns>A circle of curvature in a given point of curve</returns>
        public GlCircle getCurvatureCircle(GlPointR2 belongsPoint)
        {
            if (belongsPoint == null || belongsPoint.isNullPoint() || !this.isPointBelongs(belongsPoint))
            {
                return(new GlCircle(float.NaN, new GlPointR2(float.NaN, float.NaN)));
            }

            GlPointR2 P = belongsPoint.getPointTranslatedToRotatedSystem(SIN, COS, Center);

            float sDiff = getSDiff(P.X);

            if (sDiff == 0)
            {
                return(new GlCircle(float.NaN, new GlPointR2(float.NaN, float.NaN)));
            }

            float fDiff    = getFDiff(P.X);
            float fDiffPow = (float)Math.Pow(fDiff, 2.0);

            return(new GlCircle((float)(Math.Pow(1 + fDiffPow, 1.5) / Math.Abs(sDiff)),
                                new GlPointR2(P.X - fDiff * (1 + fDiffPow) / sDiff,
                                              P.Y + (P.Y < 0 ? -1 : 1) * (1 + fDiffPow) / sDiff).getTranslatedBackPoint(SIN, COS, Center)));
        }