Example #1
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


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


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            float oldX = systemCenter.X, oldY = systemCenter.Y;

            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, oldX, oldY))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }

            GlVectorR2 moveVector = new GlVectorR2(x - this.systemCenter.X, y - this.systemCenter.Y);

            this.systemCenter = new GlPointR2(x, y);

            foreach (GlFigure F in this.figuresAmount)
            {
                GlPointR2 newCenter = moveVector.fromPointToPoint(F.Center);
                F.moveTo(newCenter.X, newCenter.Y);
            }

            if (OnMoved != null)
            {
                OnMoving.Invoke(this, oldX, oldY);
            }
        }
Example #2
0
        ///////////////////////////////////////////////
        //////////////////PROPERTIES///////////////////
        ///////////////////////////////////////////////


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


        ///////////////////////////////////////////////
        ////////////////////METHODS////////////////////
        ///////////////////////////////////////////////

        //////////////TRANSFORM_METHODS////////////////

        public override void moveTo(float x, float y)
        {
            if (OnMoveStart != null)
            {
                if (!OnMoveStart.Invoke(this, this.polyCenter.X, this.polyCenter.Y))
                {
                    return;
                }
            }

            if (OnMoving != null)
            {
                OnMoving.Invoke(this, this.polyCenter.X, this.polyCenter.Y);
            }

            GlVectorR2 delta = new GlVectorR2(x - polyCenter.X, y - polyCenter.Y);

            for (int i = 0; i < vertexes.Length; i++)
            {
                vertexes[i] = delta.fromPointToPoint(vertexes[i]);
            }

            GlPointR2 OP = new GlPointR2(this.polyCenter);

            this.polyCenter = new GlPointR2(x, y);

            if (OnMoved != null)
            {
                OnMoved.Invoke(this, OP.X, OP.Y);
            }
        }
Example #3
0
        //////////////TRANSFORM_METHODS////////////////
        ///////////////////////////////////////////////
        /////////////INTERSECTION_METHODS//////////////

        public override GlPointR2[] getIntersection(GlLineR2 L)
        {
            GlVectorR2 translatedVector = new GlVectorR2(L.DirectVector).getRotatedVector(this.SIN, this.COS);
            GlPointR2  FP = L.PointOfLine.getPointTranslatedToRotatedSystem(this.SIN, this.COS, this.Center);
            GlPointR2  SP = translatedVector.fromPointToPoint(FP);

            float fPartRes = (float)Math.Pow(AdditionalHalfAixis * (FP.X - SP.X), 2.0);
            float sPartRes = (float)Math.Pow(RealHalfAixis * (FP.Y - SP.Y), 2.0);
            float tPartRes = FP.X * SP.Y - SP.X * FP.Y;
            float sqrtPart = RealHalfAixis * AdditionalHalfAixis * (FP.X - SP.X) * (float)Math.Sqrt(fPartRes - sPartRes + Math.Pow(tPartRes, 2.0));

            float x1 = (-(float)Math.Pow(RealHalfAixis, 2.0) * (FP.Y - SP.Y) * tPartRes + sqrtPart) / (sPartRes - fPartRes);
            float x2 = (-(float)Math.Pow(RealHalfAixis, 2.0) * (FP.Y - SP.Y) * tPartRes - sqrtPart) / (sPartRes - fPartRes);

            float y1 = AdditionalHalfAixis * (float)Math.Sqrt(x1 * x1 - Math.Pow(RealHalfAixis, 2.0)) / RealHalfAixis;
            float y2 = -AdditionalHalfAixis * (float)Math.Sqrt(x2 * x2 - Math.Pow(RealHalfAixis, 2.0)) / RealHalfAixis;

            float y3 = -AdditionalHalfAixis * (float)Math.Sqrt(x1 * x1 - Math.Pow(RealHalfAixis, 2.0)) / RealHalfAixis;
            float y4 = AdditionalHalfAixis * (float)Math.Sqrt(x2 * x2 - Math.Pow(RealHalfAixis, 2.0)) / RealHalfAixis;

            GlPointR2[] RP =
            {
                new GlPointR2(x1, y1).getTranslatedBackPoint(this.SIN, this.COS, this.Center),
                new GlPointR2(x2, y2).getTranslatedBackPoint(this.SIN, this.COS, this.Center),
                new GlPointR2(x1, y3).getTranslatedBackPoint(this.SIN, this.COS, this.Center),
                new GlPointR2(x2, y4).getTranslatedBackPoint(this.SIN, this.COS, this.Center)
            };

            List <GlPointR2> res = new List <GlPointR2>();

            for (int i = 0; i < RP.Length; i++)
            {
                bool a = this.isPointBelongs(RP[i]);
                bool b = L.isPointBelongs(RP[i]);
                if (a && b)
                {
                    res.Add(RP[i]);
                }
            }

            return(res.ToArray());
        }