コード例 #1
0
        public static Plot2D operator +(PPoint2D a, PPoint2D b)
        {
            Plot2D   plot2D = new Plot2D();
            PPoint2D p1     = a;

            plot2D.AddPoint(p1);
            PPoint2D p2 = b;

            plot2D.AddPoint(p2);
            return(plot2D);
        }
コード例 #2
0
        public static Plot2D operator *(Plot2D a, ITransformation2D b)
        {
            var l = a._points.ConvertAll(el => new PPoint2D(el.X, el.Y, el.Color, el.Visible));

            Parallel.For(0, a._points.Count, i =>
            {
                PPoint2D point = a._points[i];
                b.Transform(ref point, l);
                a._points[i] = point;
            });
            return(a);
        }
コード例 #3
0
        public static Plot2D operator /(Plot2D a, ITransformation2D b)
        {
            var l = a._points.ConvertAll(el => new PPoint2D(el.X, el.Y, el.Color, el.Visible));

            Parallel.For(0, a._points.Count, i =>
            {
                PPoint2D point = a._points[i];
                INvertibleTransformation2D transformation2D = b as INvertibleTransformation2D;
                if (transformation2D == null)
                {
                    throw new InvalidCastException("Transformation not invertible!");
                }
                transformation2D.Invert(ref point, l);
                a._points[i] = point;
            });
            return(a);
        }
コード例 #4
0
        public static Plot2D Line2D(float dx, PPoint2D a, PPoint2D b, Color color)
        {
            Plot2D plot2D = new Plot2D();
            var    num1   = a.X - b.X;
            var    num2   = a.Y - b.Y;
            var    num3   = (float)Math.Sqrt(num1 * (double)num1 + num2 * (double)num2);
            var    num4   = num1 / num3;
            var    num5   = num2 / num3;
            var    num6   = 0.0f;

            while (num6 <= (double)num3)
            {
                plot2D.AddPoint(new PPoint2D(num6 * num4 + b.X, num6 * num5 + b.Y, color));
                num6 += dx;
            }
            return(plot2D);
        }
コード例 #5
0
        public Bitmap ToBitMap(int w, int h, RectangleF view)
        {
            var      x1       = view.X;
            var      num1     = view.X + view.Width;
            var      y1       = view.Y;
            var      num2     = view.Y + view.Height;
            Bitmap   bitmap   = new Bitmap(w, h, PixelFormat.Format24bppRgb);
            Graphics graphics = Graphics.FromImage(bitmap);

            if (Math.Abs(num1 - x1) + (double)Math.Abs(num2 - y1) < 5.60519385729927E-44)
            {
                graphics.Clear(Color.Black);
            }
            else
            {
                Font font = new Font("Comic Sans", 12f);
                graphics.Clear(Color.White);
                var num3 = (float)(w * 0.899999976158142 / (num1 - (double)x1));
                var num4 = (float)(h * 0.899999976158142 / (num2 - (double)y1));
                var num5 = Size * 0.5f;
                var num6 = w * 0.025f;
                var num7 = h * 0.025f;
                graphics.DrawLine(Pens.Black, new PointF(-x1 * num3 + num6, h), new PointF(-x1 * num3 + num6, 0.0f));
                graphics.DrawLine(Pens.Black, new PointF(w, -y1 * num4 + num7), new PointF(0.0f, -y1 * num4 + num7));
                if (Math.Abs(LinesH) > 4.20389539297445E-45)
                {
                    for (var index = (int)Math.Floor(y1 / (double)LinesH) - 1;
                         (double)index < Math.Ceiling(num2 / (double)LinesH) + 1.0;
                         ++index)
                    {
                        graphics.DrawLine(Pens.Black, new PointF(-x1 * num3, (num2 - index * LinesH) * num4 + num7),
                                          new PointF((float)(-(double)x1 * num3 + 2.0 * num6), (num2 - index * LinesH) * num4 + num7));
                        graphics.DrawString(index.ToString(), font, Brushes.Black,
                                            new PointF((float)(-(double)x1 * num3 - 2.0 * num6),
                                                       (float)((num2 - index * (double)LinesH) * num4 - 1.5 * num7)));
                    }
                }
                if (Math.Abs(LinesV) > 4.20389539297445E-45)
                {
                    for (var index = (int)Math.Floor(x1 / (double)LinesV) - 1;
                         (double)index < Math.Ceiling(num1 / (double)LinesV) + 1.0;
                         ++index)
                    {
                        if (index != 0)
                        {
                            graphics.DrawLine(Pens.Black, new PointF((index * LinesV - x1) * num3 + num6, -y1 * num4),
                                              new PointF((index * LinesV - x1) * num3 + num6,
                                                         (float)(-(double)y1 * num4 + 2.0 * num7)));
                            graphics.DrawString(index.ToString(), font, Brushes.Black,
                                                new PointF((index * LinesV - x1) * num3, (float)(-(double)y1 * num4 + 2.5 * num7)));
                        }
                    }
                }
                var num8  = num6 - num5;
                var num9  = num7 - num5;
                var num10 = 0.0f;
                var num11 = 0.0f;
                for (var index = 0; index < _points.Count; ++index)
                {
                    PPoint2D ppoint2D = _points[index];
                    if (ppoint2D.Visible)
                    {
                        var x2 = (ppoint2D.X - x1) * num3 + num8;
                        var y2 = (num2 - ppoint2D.Y) * num4 + num9;
                        if (Connect && index != 0)
                        {
                            graphics.DrawLine(new Pen(ppoint2D.Color, Size), x2 + num5, y2 + num5, num10 + num5,
                                              num11 + num5);
                        }
                        else
                        {
                            graphics.FillEllipse(new SolidBrush(ppoint2D.Color), x2, y2, Size, Size);
                        }
                        num10 = x2;
                        num11 = y2;
                    }
                }
            }
            return(bitmap);
        }
コード例 #6
0
        public Bitmap ToBitMap(int w, int h)
        {
            var num1 = float.MaxValue;
            var num2 = float.MinValue;
            var num3 = float.MaxValue;
            var num4 = float.MinValue;

            foreach (PPoint2D point in _points)
            {
                if (point.X < (double)num1)
                {
                    num1 = point.X;
                }
                if (point.X > (double)num2)
                {
                    num2 = point.X;
                }
                if (point.Y < (double)num3)
                {
                    num3 = point.Y;
                }
                if (point.Y > (double)num4)
                {
                    num4 = point.Y;
                }
            }
            Bitmap   bitmap    = new Bitmap(w, h, PixelFormat.Format24bppRgb);
            Graphics graphics1 = Graphics.FromImage(bitmap);

            if (_points.Count < 2 || Math.Abs(num2 - num1) + (double)Math.Abs(num4 - num3) < 5.60519385729927E-44)
            {
                graphics1.Clear(Color.Black);
            }
            else
            {
                Font font1 = new Font("Comic Sans", 12f);
                graphics1.Clear(Color.White);
                var num5 = (float)(w * 0.899999976158142 / (num2 - (double)num1));
                var num6 = (float)(h * 0.899999976158142 / (num4 - (double)num3));
                var num7 = Size * 0.5f;
                var num8 = w * 0.025f;
                var num9 = h * 0.025f;
                graphics1.DrawLine(Pens.Black, new PointF(-num1 * num5 + num8, h), new PointF(-num1 * num5 + num8, 0.0f));
                graphics1.DrawLine(Pens.Black, new PointF(w, -num3 * num6 + num9), new PointF(0.0f, -num3 * num6 + num9));
                float num10;
                if (Math.Abs(LinesH) > 4.20389539297445E-45)
                {
                    for (var index = (int)Math.Floor(num3 / (double)LinesH) - 1;
                         (double)index < Math.Ceiling(num4 / (double)LinesH) + 1.0;
                         ++index)
                    {
                        graphics1.DrawLine(Pens.Black, new PointF(-num1 * num5, (num4 - index * LinesH) * num6 + num9),
                                           new PointF((float)(-(double)num1 * num5 + 2.0 * num8),
                                                      (num4 - index * LinesH) * num6 + num9));
                        Graphics graphics2 = graphics1;
                        num10 = index * LinesH;
                        var    @string = num10.ToString(CultureInfo.CurrentCulture);
                        Font   font2   = font1;
                        Brush  black   = Brushes.Black;
                        PointF point   = new PointF((float)(-(double)num1 * num5 + 0.5 * num8),
                                                    (num4 - index * LinesH) * num6);
                        graphics2.DrawString(@string, font2, black, point);
                    }
                }
                if (Math.Abs(LinesV) > 4.20389539297445E-45)
                {
                    for (var index = (int)Math.Floor(num1 / (double)LinesV) - 1;
                         (double)index < Math.Ceiling(num2 / (double)LinesV) + 1.0;
                         ++index)
                    {
                        if (index != 0)
                        {
                            graphics1.DrawLine(Pens.Black,
                                               new PointF((index * LinesV - num1) * num5 + num8, -num3 * num6),
                                               new PointF((index * LinesV - num1) * num5 + num8,
                                                          (float)(-(double)num3 * num6 + 2.0 * num9)));
                            Graphics graphics2 = graphics1;
                            num10 = index * LinesV;
                            var    @string = num10.ToString(CultureInfo.CurrentCulture);
                            Font   font2   = font1;
                            Brush  black   = Brushes.Black;
                            PointF point   = new PointF((float)((index * (double)LinesV - num1) * num5 + 0.5 * num8),
                                                        -num3 * num6 + num9);
                            graphics2.DrawString(@string, font2, black, point);
                        }
                    }
                }
                var num11 = num8 - num7;
                var num12 = num9 - num7;
                var num13 = 0.0f;
                var num14 = 0.0f;
                for (var index = 0; index < _points.Count; ++index)
                {
                    PPoint2D ppoint2D = _points[index];
                    if (ppoint2D.Visible)
                    {
                        var x = (ppoint2D.X - num1) * num5 + num11;
                        var y = (num4 - ppoint2D.Y) * num6 + num12;
                        if (Connect && index != 0)
                        {
                            graphics1.DrawLine(new Pen(ppoint2D.Color, Size), x + num7, y + num7, num13 + num7,
                                               num14 + num7);
                        }
                        else
                        {
                            graphics1.FillEllipse(new SolidBrush(ppoint2D.Color), x, y, Size, Size);
                        }
                        num13 = x;
                        num14 = y;
                    }
                }
            }
            return(bitmap);
        }
コード例 #7
0
 public void AddPoint(PPoint2D p)
 {
     _points.Add(p);
 }
コード例 #8
0
        public Bitmap ToBitMap(int w, int h, Rectangle3D view, PPoint3D light)
        {
            var          num1     = view.X;
            var          num2     = view.X + view.Width;
            var          num3     = view.Y;
            var          num4     = view.Y + view.Height;
            DistComparer comparer = new DistComparer
            {
                CamX = (float)(num1 - 0.0500000007450581 * (num2 - (double)num1)),
                CamY = (float)(num3 - 0.0500000007450581 * (num4 - (double)num3)),
                CamZ = (float)(MaxZ * 1.04999995231628)
            };

            _points.Sort(comparer);
            var ppoint2DList = new List <PPoint2D>();

            foreach (PPoint3D point in _points)
            {
                PPoint2D ppoint2D1 = new PPoint2D((float)(0.5 * (point.X - (double)point.Y)), 0.5f * point.Y + point.Z,
                                                  point.Color);
                var num5 = point.Visible ? 1 : 0;
                ppoint2D1.Visible = num5 != 0;
                PPoint2D ppoint2D2 = ppoint2D1;
                ppoint2DList.Add(ppoint2D2);
            }
            Bitmap   bitmap   = new Bitmap(w, h, PixelFormat.Format24bppRgb);
            Graphics graphics = Graphics.FromImage(bitmap);

            if (Math.Abs(num2 - num1) + (double)Math.Abs(num4 - num3) < 5.60519385729927E-44)
            {
                graphics.Clear(Color.Black);
            }
            else
            {
                graphics.Clear(Color.White);
                var num5  = (float)(w * 0.899999976158142 / (num2 - (double)num1));
                var num6  = (float)(h * 0.899999976158142 / (num4 - (double)num3));
                var num7  = MaxZ - MinZ;
                var num8  = Size * 0.5f;
                var num9  = w * 0.025f;
                var num10 = h * 0.025f;
                var num11 = 1f / num9;
                var num12 = 1f / num10;
                var num13 = (float)((num12 + (double)num11) * 0.100000001490116);
                var num14 = num9 - num8;
                var num15 = num10 - num8;
                for (var index = 0; index < ppoint2DList.Count; ++index)
                {
                    PPoint2D ppoint2D = ppoint2DList[index];
                    if (ppoint2D.Visible)
                    {
                        var d = ColorLight(_points[index], comparer, light);
                        var x = (ppoint2D.X - num1) * num5 + num14;
                        var y = (num4 - ppoint2D.Y) * num6 + num15;
                        if (Math.Abs(LinesH) > 4.20389539297445E-45 && Extensions.Mod(_points[index].X, LinesH) < num11 ||
                            Math.Abs(LinesV) > 4.20389539297445E-45 && Extensions.Mod(_points[index].Y, LinesV) < num12 ||
                            Math.Abs(LinesL) > 4.20389539297445E-45 && Extensions.Mod(_points[index].Z, LinesL) < num13)
                        {
                            graphics.FillEllipse(Brushes.Black, x, y, Size, Size);
                        }
                        else if (ppoint2D.Color == Color.Empty)
                        {
                            graphics.FillEllipse(
                                new SolidBrush(
                                    ColorMultiply(
                                        Extensions.HsvToRgb(360.0 * (_points[index].Z - (double)MinZ) / num7, 1.0, 1.0),
                                        d)), x, y, Size, Size);
                        }
                        else
                        {
                            graphics.FillEllipse(new SolidBrush(ColorMultiply(ppoint2D.Color, d)), x, y, Size, Size);
                        }
                    }
                }
            }
            return(bitmap);
        }
コード例 #9
0
        public Bitmap ToBitMap(int w, int h)
        {
            var num1 = float.MaxValue;
            var num2 = float.MinValue;
            var num3 = float.MaxValue;
            var num4 = float.MinValue;

            foreach (PPoint3D point in _points)
            {
                if (point.X < (double)num1)
                {
                    num1 = point.X;
                }
                if (point.X > (double)num2)
                {
                    num2 = point.X;
                }
                if (point.Y < (double)num3)
                {
                    num3 = point.Y;
                }
                if (point.Y > (double)num4)
                {
                    num4 = point.Y;
                }
            }
            _points.Sort(new DistComparer
            {
                CamX = (float)(num1 - 0.0500000007450581 * (num2 - (double)num1)),
                CamY = (float)(num3 - 0.0500000007450581 * (num4 - (double)num3)),
                CamZ = (float)(MaxZ * 1.04999995231628)
            });
            var num5         = float.MaxValue;
            var num6         = float.MinValue;
            var num7         = float.MaxValue;
            var num8         = float.MinValue;
            var ppoint2DList = new List <PPoint2D>();

            foreach (PPoint3D point in _points)
            {
                PPoint2D ppoint2D = new PPoint2D((float)(0.5 * (point.X - (double)point.Y)), 0.5f * point.Y + point.Z,
                                                 point.Color, point.Visible);
                ppoint2DList.Add(ppoint2D);
                if (ppoint2D.X < (double)num5)
                {
                    num5 = ppoint2D.X;
                }
                if (ppoint2D.X > (double)num6)
                {
                    num6 = ppoint2D.X;
                }
                if (ppoint2D.Y < (double)num7)
                {
                    num7 = ppoint2D.Y;
                }
                if (ppoint2D.Y > (double)num8)
                {
                    num8 = ppoint2D.Y;
                }
            }
            Bitmap   bitmap   = new Bitmap(w, h, PixelFormat.Format24bppRgb);
            Graphics graphics = Graphics.FromImage(bitmap);

            if (_points.Count < 2 || Math.Abs(num6 - num5) + (double)Math.Abs(num8 - num7) < 5.60519385729927E-44)
            {
                graphics.Clear(Color.Black);
            }
            else
            {
                graphics.Clear(Color.White);
                var num9  = (float)(w * 0.899999976158142 / (num6 - (double)num5));
                var num10 = (float)(h * 0.899999976158142 / (num8 - (double)num7));
                var num11 = MaxZ - MinZ;
                var num12 = Size * 0.5f;
                var num13 = w * 0.025f;
                var num14 = h * 0.025f;
                var num15 = 1f / num13;
                var num16 = 1f / num14;
                var num17 = (float)((num16 + (double)num15) * 0.100000001490116);
                var num18 = num13 - num12;
                var num19 = num14 - num12;
                for (var index = 0; index < ppoint2DList.Count; ++index)
                {
                    PPoint2D ppoint2D = ppoint2DList[index];
                    if (ppoint2D.Visible)
                    {
                        var x = (ppoint2D.X - num5) * num9 + num18;
                        var y = (num8 - ppoint2D.Y) * num10 + num19;
                        if (Math.Abs(LinesH) > 4.20389539297445E-45 && Extensions.Mod(_points[index].X, LinesH) < num15 ||
                            Math.Abs(LinesV) > 4.20389539297445E-45 && Extensions.Mod(_points[index].Y, LinesV) < num16 ||
                            Math.Abs(LinesL) > 4.20389539297445E-45 && Extensions.Mod(_points[index].Z, LinesL) < num17)
                        {
                            graphics.FillEllipse(Brushes.Black, x, y, Size, Size);
                        }
                        else if (ppoint2D.Color == Color.Empty)
                        {
                            graphics.FillEllipse(
                                new SolidBrush(Extensions.HsvToRgb(360.0 * (_points[index].Z - (double)MinZ) / num11,
                                                                   1.0, 1.0)), x, y, Size, Size);
                        }
                        else
                        {
                            graphics.FillEllipse(new SolidBrush(ppoint2D.Color), x, y, Size, Size);
                        }
                    }
                }
            }
            return(bitmap);
        }