protected virtual PointD Chop (IFigure target, PointD point) {	
			if (target == null) {
				return new PointD (0, 0);
			}
			
			else if (target.ContainsPoint (point.X, point.Y)) {
				return target.DisplayBox.Center;
			}

			double angle = Geometry.AngleFromPoint (DisplayBox, point);
			return Geometry.EdgePointFromAngle (DisplayBox, angle);
		}
		protected override PointD Chop (IFigure target, PointD point) {
			if (target.ContainsPoint (point.X, point.Y)) {
				return target.DisplayBox.Center;
			}

			double angle = Geometry.AngleFromPoint (DisplayBox, point);
			
			PointD p = new PointD (0.0, 0.0);
			RectangleD r = target.DisplayBox;
			
			p.X = r.Center.X + r.Width/2 * Math.Cos (angle);
			p.Y = r.Center.Y + r.Height/2 * Math.Sin (angle);
			
			return p;
		}
Esempio n. 3
0
        protected override PointD Chop(IFigure target, PointD point)
        {
            if (target.ContainsPoint (point.X, point.Y)) {
                return target.DisplayBox.Center;
            }

            double angle = Geometry.AngleFromPoint (DisplayBox, point);
            double sin = Math.Sin (angle);
            double cos = Math.Cos (angle);
            double x = 0;
            double e = 0.0001;
            double y = 0;
            RectangleD r = DisplayBox;

            if (Math.Abs (sin) > e) {
                x = (1.0 + cos / Math.Abs (sin)) / 2.0 * r.Width;
                x = Geometry.Range (0.0, r.Width, x);
            } else if (cos >= 0.0) {
                x = r.Width;
            }

            if (Math.Abs (cos) > e) {
                y = (1.0 + sin / Math.Abs (cos)) / 2.0 * r.Height;
                y = Geometry.Range (0.0, r.Height, y);
            } else if (sin >= 0.0) {
                y = r.Height;
            }

            x += r.X;// - (x + r.X > r.X + r.Width/2 ? (r.Width/2) * -1 : (r.Width/2));
            if (x > r.X + r.Width / 2) {
                //x = r.X + r.Width / 2;
                Console.WriteLine ("Decrementar la mitad ancho");
            } else {
            //				x -= r.Width / 2;
                Console.WriteLine ("Aumentar la mitad ancho");
            }
            y += r.Y;// - (y > (r.Y + r.Height) / 2 ? (r.Y + r.Height) / 2 : 0);
            if (y > r.Y + r.Height / 2) {
                Console.WriteLine ("Aumentar la mitad altura");
            //	y += r.Height / 2;
            } else {
                //y = r.Y + r.Height / 2;
                Console.WriteLine ("Decrementar la mitad altura");
            //	y -= r.Height / 2;
            }

            return new PointD (x, y);
        }
Esempio n. 4
0
        protected virtual PointD Chop(IFigure target, PointD point)
        {
            if (target == null)
            {
                return(new PointD(0, 0));
            }

            else if (target.ContainsPoint(point.X, point.Y))
            {
                return(target.DisplayBox.Center);
            }

            double angle = Geometry.AngleFromPoint(DisplayBox, point);

            return(Geometry.EdgePointFromAngle(DisplayBox, angle));
        }
Esempio n. 5
0
        protected override PointD Chop(IFigure target, PointD point)
        {
            if (target.ContainsPoint(point.X, point.Y))
            {
                return(target.DisplayBox.Center);
            }

            double angle = Geometry.AngleFromPoint(DisplayBox, point);

            PointD     p = new PointD(0.0, 0.0);
            RectangleD r = target.DisplayBox;

            p.X = r.Center.X + r.Width / 2 * Math.Cos(angle);
            p.Y = r.Center.Y + r.Height / 2 * Math.Sin(angle);

            return(p);
        }