Exemplo n.º 1
0
        private Size scaleToScreen(flPoint p)
        {
            //return p;

            Size value = new Size();

            value.Width  = (int)Math.Round((szScreen.Width * p.X) / szViewport.Width);
            value.Height = (int)Math.Round((szScreen.Height * p.Y) / szViewport.Height);

            return(value);
        }
Exemplo n.º 2
0
        private Point viewportToScreen(flPoint p)
        {
            //return p;

            Point value = new Point();

            value.X = (int)Math.Round((szScreen.Width * p.X) / szViewport.Width);
            value.Y = szScreen.Height - (int)Math.Round((szScreen.Height * p.Y) / szViewport.Height);
            //value.Y = (szScreen.Height - (szScreen.Height * p.Y) / szViewport.Height) * -1;

            return(value);
        }
Exemplo n.º 3
0
        private void DrawCircle(Graphics g, flPoint c, double r)
        {
            Point     scrCenter   = viewportToScreen(c);
            Size      scrRadii    = scaleToScreen(new flPoint(r, r));
            Rectangle boundingRec = new Rectangle(scrCenter.X - scrRadii.Width, scrCenter.Y - scrRadii.Height,
                                                  2 * scrRadii.Width, 2 * scrRadii.Height);

            g.DrawEllipse(currentPen, 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 quadrent
            // 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);
        }
Exemplo n.º 4
0
        private void DrawArc(Graphics g, flPoint c, double r, double a)
        {
            int tessellation = (int)Math.Ceiling(circularTessellation * Math.Abs(a) / 360.0);

            flPoint[] arc        = new flPoint[tessellation + 1];
            double    deltaAngle = (2 * Math.PI) / circularTessellation;

            if (a < 0)
            {
                deltaAngle *= -1;
            }
            for (int idx = 0; idx <= tessellation; idx++)
            {
                double angle = (deltaAngle * idx);
                double x     = Math.Sin(angle) * r + c.X;
                double y     = Math.Cos(angle) * r + c.Y;
                arc[idx] = new flPoint(x, y);
            }
            DrawPolyLine(g, arc);
        }
Exemplo n.º 5
0
 private void DrawLine(Graphics g, flPoint p1, flPoint p2)
 {
     g.DrawLine(currentPen, viewportToScreen(p1), viewportToScreen(p2));
 }
Exemplo n.º 6
0
 public Line Scale(flPoint scale)
 {
     return(new Line(P1.Scale(scale), P2.Scale(scale)));
 }
Exemplo n.º 7
0
        //public flPoint(Point p) { X = p.X; Y = p.Y; }

        public Line Translate(flPoint delta)
        {
            return(new Line(P1.Translate(delta), P2.Translate(delta)));
        }
Exemplo n.º 8
0
 public Line(Point p1, Point p2)
 {
     P1 = new flPoint(p1); P2 = new flPoint(p2);
 }
Exemplo n.º 9
0
 public Line(flPoint p1, flPoint p2)
 {
     P1 = p1; P2 = p2;
 }
Exemplo n.º 10
0
 public flPoint Scale(flPoint scale)
 {
     return(new flPoint(X * scale.X, Y * scale.Y));
 }
Exemplo n.º 11
0
 public flPoint Translate(flPoint delta)
 {
     return(new flPoint(X + delta.X, Y + delta.Y));
 }