Beispiel #1
0
        public Triangle(IflPoint center, IflPoint[] corners, bool fill = false, double orientation = 0)
        {
            Center      = center;
            Fill        = fill;
            Orientation = orientation;
            Points      = new IflPoint[3];

            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;

            for (int idx = 0; idx < 3; idx++)
            {
                Points[idx] = corners[idx];

                if (Points[idx].X > maxX)
                {
                    maxX = Points[idx].X;
                }
                if (Points[idx].X < minX)
                {
                    minX = Points[idx].X;
                }
                if (Points[idx].Y > maxY)
                {
                    maxY = Points[idx].Y;
                }
                if (Points[idx].Y < minY)
                {
                    minY = Points[idx].Y;
                }
            }
            Size = Globals.Classfactory.NewflPoint((maxX - minX / 2), (maxY - minY / 2));
        }
Beispiel #2
0
 public static IflPoint[] RotateRad(IflPoint[] points, double radians)
 {
     IflPoint[] value = new IflPoint[points.Length];
     for (int idx = 0; idx < points.Length; idx++)
     {
         value[idx] = points[idx].RotateRad(radians);
     }
     return(value);
 }
Beispiel #3
0
 public static IflPoint[] Scale(IflPoint[] points, double sx, double sy)
 {
     IflPoint[] value = new IflPoint[points.Length];
     for (int idx = 0; idx < points.Length; idx++)
     {
         value[idx] = points[idx].Scale(sx, sy);
     }
     return(value);
 }
Beispiel #4
0
 public static IflPoint[] Translate(IflPoint[] points, IflPoint delta)
 {
     IflPoint[] value = new IflPoint[points.Length];
     for (int idx = 0; idx < points.Length; idx++)
     {
         value[idx] = points[idx].Translate(delta);
     }
     return(value);
 }
Beispiel #5
0
 public static IflPoint[] Scale(IflPoint[] points, IflPoint scale)
 {
     IflPoint[] value = new IflPoint[points.Length];
     for (int idx = 0; idx < points.Length; idx++)
     {
         value[idx] = (flPoint)points[idx].Scale(scale);
     }
     return(value);
 }
Beispiel #6
0
        private Point viewportToScreen(IflPoint p)
        {
            Point value = new Point();

            value.X = (int)Math.Round((szScreen.X * (p.X + ptViewport.X)) / szViewport.X);
            value.Y = (int)Math.Round(szScreen.Y - (szScreen.Y * (p.Y + ptViewport.Y)) / szViewport.Y);

            return(value);
        }
Beispiel #7
0
        public void DrawCircle(IflPoint c, double r, bool fill = false)
        {
            Graphics g         = this;
            Point    scrCenter = viewportToScreen(c);
            flPoint  scrRadii  = scaleToScreen(new flPoint(r, r));

            System.Drawing.Rectangle boundingRec = new System.Drawing.Rectangle(
                (int)Math.Round(scrCenter.X - scrRadii.X), (int)Math.Round(scrCenter.Y - scrRadii.Y),
                (int)Math.Round(2 * scrRadii.X), (int)Math.Round(2 * scrRadii.Y));
            g.DrawEllipse(CurrentPen as Pen, boundingRec);
            if (fill)
            {
                g.FillEllipse(CurrentBrush as Brush, boundingRec);
            }

            // flPoint[] circle = new flPoint[circularTessellation];
            // flPoint[] quarterCircle = new flPoint[circularTessellation/4];
            // double deltaAngle = (2 * Math.PI) / circularTessellation;
            // // first half quadrent
            // for (int idx = 0; idx < circularTessellation / 8; idx++)
            // {
            //     double angle = (deltaAngle * idx) + (deltaAngle/2);
            //     double x = Math.Sin(angle) * r;
            //     double y = Math.Cos(angle) * r;
            //     quarterCircle[idx] = new flPoint(x, y);
            //     circle[idx] = quarterCircle[idx].Translate(c);
            // }
            // //DrawPolygon(g, circle);
            // // second half quadrent
            // for (int idx = 0; idx < circularTessellation / 8; idx++)
            // {
            //     quarterCircle[idx + circularTessellation / 8] =
            //         new flPoint(quarterCircle[(circularTessellation / 8) - idx - 1].Y,
            //                     quarterCircle[(circularTessellation / 8) - idx - 1].X);
            //     circle[idx + circularTessellation / 8] = quarterCircle[idx + circularTessellation / 8].Translate(c);
            // }
            // //DrawPolygon(g, circle);
            // // second quadrant
            // for (int idx = 0; idx < circularTessellation / 4; idx++)
            // {
            //     circle[idx + circularTessellation / 4] = quarterCircle[circularTessellation / 4 - idx - 1].Scale(1, -1).Translate(c);
            // }
            // //DrawPolygon(g, circle);
            // // third quadrent
            // for (int idx = 0; idx < circularTessellation / 4; idx++)
            // {
            //     circle[idx + circularTessellation / 2] = quarterCircle[idx].Scale(-1, -1).Translate(c);
            // }
            // //DrawPolygon(g, circle);
            //// fourth quadrent
            // for (int idx = 0; idx < circularTessellation / 4; idx++)
            // {
            //     circle[idx + ((circularTessellation * 3) / 4)] = quarterCircle[circularTessellation / 4 - idx - 1].Scale(-1, 1).Translate(c);
            // }
            // DrawPolygon(g, circle);
        }
Beispiel #8
0
        public IsoscelesTriangle(IflPoint center, IflPoint size, bool fill = false, double orientation = 0)
        {
            Center      = center;
            Size        = size;
            Fill        = fill;
            Orientation = orientation;
            Points      = new IflPoint[3];

            Points[0] = Globals.Classfactory.NewflPoint(-size.X / 2, -size.Y / 2);
            Points[1] = Globals.Classfactory.NewflPoint(size.X / 2, -size.Y / 2);
            Points[2] = Globals.Classfactory.NewflPoint(0, size.Y / 2);
        }
Beispiel #9
0
        public void DrawPoint(IflPoint p)
        {
            Graphics g         = this;
            Point    scrCenter = viewportToScreen(p);
            flPoint  scrRadii  = scaleToScreen(new flPoint(.5, .5));

            System.Drawing.Rectangle boundingRec = new System.Drawing.Rectangle(
                (int)Math.Round(scrCenter.X - scrRadii.X), (int)Math.Round(scrCenter.Y - scrRadii.Y),
                (int)Math.Round(2 * scrRadii.X), (int)Math.Round(2 * scrRadii.Y));
            //g.DrawEllipse(CurrentPen as Pen, boundingRec);
            g.FillEllipse(CurrentBrush as Brush, boundingRec);
        }
Beispiel #10
0
        public RegularPolygon(IflPoint center, int numSides, double radius, bool fill = false, double orientation = 0)
        {
            Center      = center;
            Radius      = radius;
            Fill        = fill;
            Orientation = orientation;
            Points      = new IflPoint[numSides];

            double deltaAngle = 2.0 * Math.PI / numSides;
            double minX       = double.MaxValue;
            double maxX       = double.MinValue;
            double minY       = double.MaxValue;
            double maxY       = double.MinValue;

            for (int idx = 0; idx < numSides; idx++)
            {
                double angle = idx * deltaAngle;

                Points[idx] = Globals.Classfactory.NewflPoint(radius * Math.Sin(angle), radius * Math.Cos(angle));

                if (Points[idx].X > maxX)
                {
                    maxX = Points[idx].X;
                }
                if (Points[idx].X < minX)
                {
                    minX = Points[idx].X;
                }
                if (Points[idx].Y > maxY)
                {
                    maxY = Points[idx].Y;
                }
                if (Points[idx].Y < minY)
                {
                    minY = Points[idx].Y;
                }
            }

            Size = Globals.Classfactory.NewflPoint((maxX - minX / 2), (maxY - minY / 2));
        }
Beispiel #11
0
        public EquilateralTriangle(IflPoint center, float radius, bool fill = false, double orientation = 0)
        {
            Radius      = radius;
            Center      = center;
            Fill        = fill;
            Orientation = orientation;
            Points      = new IflPoint[3];

            double dx = Math.Sin(Math.PI / 3) * radius;

            Points[0] = Globals.Classfactory.NewflPoint(-dx, -radius / 2);
            Points[1] = Globals.Classfactory.NewflPoint(dx, -radius / 2);
            Points[2] = Globals.Classfactory.NewflPoint(0, radius);

            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;

            for (int idx = 0; idx < 3; idx++)
            {
                if (Points[idx].X > maxX)
                {
                    maxX = Points[idx].X;
                }
                if (Points[idx].X < minX)
                {
                    minX = Points[idx].X;
                }
                if (Points[idx].Y > maxY)
                {
                    maxY = Points[idx].Y;
                }
                if (Points[idx].Y < minY)
                {
                    minY = Points[idx].Y;
                }
            }
            Size = Globals.Classfactory.NewflPoint((maxX - minX / 2), (maxY - minY / 2));
        }
Beispiel #12
0
 public Line(IflPoint p1, IflPoint p2)
 {
     P1 = p1; P2 = p2;
 }
Beispiel #13
0
 public IflPoint Translate(IflPoint delta)
 {
     return(new flPoint(X + delta.X, Y + delta.Y));
 }
Beispiel #14
0
 public IflPoint Scale(IflPoint scale)
 {
     return(new flPoint(X * scale.X, Y * scale.Y));
 }
Beispiel #15
0
        public void DrawLine(IflPoint p1, IflPoint p2)
        {
            Graphics g = this;

            g.DrawLine(CurrentPen as Pen, viewportToScreen(p1), viewportToScreen(p2));
        }
Beispiel #16
0
        //public flPoint(Point p) { X = p.X; Y = p.Y; }

        public ILine Translate(IflPoint delta)
        {
            return(new Line(P1.Translate(delta), P2.Translate(delta)));
        }
Beispiel #17
0
 public ILine Scale(IflPoint scale)
 {
     return(new Line(P1.Scale(scale), P2.Scale(scale)));
 }
Beispiel #18
0
 public Line(Point p1, Point p2)
 {
     P1 = new flPoint(p1); P2 = new flPoint(p2);
 }
Beispiel #19
0
 public ILine NewLine(IflPoint p1, IflPoint p2)
 {
     return(new Line(p1, p2));
 }