Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            chart3D1.C3Axes.XMin = -3;
            chart3D1.C3Axes.XMax = 3;
            chart3D1.C3Axes.YMin = -3;
            chart3D1.C3Axes.YMax = 3;
            chart3D1.C3Axes.ZMin = -8;
            chart3D1.C3Axes.ZMax = 8;
            chart3D1.C3Axes.XTick = 1;
            chart3D1.C3Axes.YTick = 1;
            chart3D1.C3Axes.ZTick = 4;

            chart3D1.C3DataSeries.XDataMin = chart3D1.C3Axes.XMin;
            chart3D1.C3DataSeries.YDataMin = chart3D1.C3Axes.YMin;
            chart3D1.C3DataSeries.XSpacing = 0.1f;
            chart3D1.C3DataSeries.YSpacing = 0.1f;
            chart3D1.C3DataSeries.XNumber = Convert.ToInt16((chart3D1.C3Axes.XMax -
                chart3D1.C3Axes.XMin) / chart3D1.C3DataSeries.XSpacing) + 1;
            chart3D1.C3DataSeries.YNumber = Convert.ToInt16((chart3D1.C3Axes.YMax -
                chart3D1.C3Axes.YMin) / chart3D1.C3DataSeries.YSpacing) + 1;

            Point3[,] pts = new Point3[chart3D1.C3DataSeries.XNumber,
                chart3D1.C3DataSeries.YNumber];
            for (int i = 0; i < chart3D1.C3DataSeries.XNumber; i++)
            {
                for (int j = 0; j < chart3D1.C3DataSeries.YNumber; j++)
                {
                    float x = chart3D1.C3DataSeries.XDataMin +
                        i * chart3D1.C3DataSeries.XSpacing;
                    float y = chart3D1.C3DataSeries.YDataMin +
                        j * chart3D1.C3DataSeries.YSpacing;
                    double zz = 3 * Math.Pow((1 - x), 2) * Math.Exp(-x * x -
                        (y + 1) * (y + 1)) - 10 * (0.2 * x - Math.Pow(x, 3) -
                        Math.Pow(y, 5)) * Math.Exp(-x * x - y * y) -
                        1 / 3 * Math.Exp(-(x + 1) * (x + 1) - y * y);
                    float z = (float)zz;
                    pts[i, j] = new Point3(x, y, z, 1);
                }
            }
            chart3D1.C3DataSeries.PointArray = pts;
        }
 //метод для построения графика
 private void AddData()
 {
     FunctionGraphik.C3Axes.XMin = (float)minX; //задаем границы для графика
     FunctionGraphik.C3Axes.XMax = (float)maxX;
     FunctionGraphik.C3Axes.YMin = (float)minY;
     FunctionGraphik.C3Axes.YMax = (float)maxY;
     FunctionGraphik.C3Labels.XLabel = "Х"; //именуем оси графика
     FunctionGraphik.C3Labels.YLabel = "Y";
     FunctionGraphik.C3Labels.ZLabel = "Z";
     FunctionGraphik.C3Labels.Title = "График функции"; //заголовок для графика
     FunctionGraphik.C3Axes.XTick = (float)((FunctionGraphik.C3Axes.XMax - FunctionGraphik.C3Axes.XMin) / 4); //для осей задаем количество меток
     FunctionGraphik.C3Axes.YTick = (float)((FunctionGraphik.C3Axes.YMax - FunctionGraphik.C3Axes.YMin) / 4);
     FunctionGraphik.C3DataSeries.XDataMin = FunctionGraphik.C3Axes.XMin; //задаем минимальные границы, чтобы график при повороте не ускакивал
     FunctionGraphik.C3DataSeries.YDataMin = FunctionGraphik.C3Axes.YMin;
     FunctionGraphik.C3DataSeries.XSpacing = (float)((FunctionGraphik.C3Axes.XMax - FunctionGraphik.C3Axes.XMin) / 20); //шаг, с которым мы увеличиваем координаты
     FunctionGraphik.C3DataSeries.YSpacing = (float)((FunctionGraphik.C3Axes.YMax - FunctionGraphik.C3Axes.YMin) / 20);
     float min = (float)Fun(FunctionGraphik.C3Axes.XMin, FunctionGraphik.C3Axes.YMin); //для поиска минимума/максимума для координаты Z
     float max = (float)Fun(FunctionGraphik.C3Axes.XMin, FunctionGraphik.C3Axes.YMin);
     for (int i = 0; i < 20; i++)
     { //задаем матрицу
         float x = FunctionGraphik.C3DataSeries.XDataMin + i * FunctionGraphik.C3DataSeries.XSpacing; //изменяем координату по Х
         for (int j = 0; j < 20; j++)
         {
             float y = FunctionGraphik.C3DataSeries.YDataMin + j * FunctionGraphik.C3DataSeries.YSpacing; //изменяем координату по Y
             float z = (float)Fun(x, y); //задаем координату Z
             pts[i, j] = new Point3(x, y, z, 1); //добавляем точку в матрицу
             if (min > z) min = z; //ищем минимум
             if (max < z) max = z; //ищем максимум
         }
     }
     FunctionGraphik.C3Axes.ZMin = (float)min; //задаем границы оси Z
     FunctionGraphik.C3Axes.ZMax = (float)max;
     FunctionGraphik.C3Axes.ZTick = (float)((max - min) / 4); //для осей задаем количество меток
     FunctionGraphik.C3ViewAngle.Elevation = PovorotElevation.Value; //задаем поворот графика
     FunctionGraphik.C3ViewAngle.Azimuth = PovorotAzimuth.Value; //задаем поворот графика
     FunctionGraphik.C3DataSeries.PointArray = pts; //"даем" графику матрицу точек
 }
        private void AddTicks(Graphics g, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            Point3[] pta = new Point3[2];
            Point3[] pts = CoordinatesOfChartBox(ax, va); ;
            Pen aPen = new Pen(ax.AxisStyle.LineColor, ax.AxisStyle.Thickness);
            aPen.DashStyle = ax.AxisStyle.Pattern;

            // Add x ticks:
            float offset = (ax.YMax - ax.YMin) / 30.0f;
            float ticklength = offset;
            for (float x = ax.XMin; x <= ax.XMax; x = x + ax.XTick)
            {
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -90 && va.Azimuth < 90)
                        ticklength = -offset;
                }
                else if (va.Elevation < 0)
                {
                    if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                        va.Azimuth >= 90 && va.Azimuth <= 180)
                        ticklength = -(ax.YMax - ax.YMin) / 30;
                }
                pta[0] = new Point3(x, pts[1].Y + ticklength, pts[1].Z, pts[1].W);
                pta[1] = new Point3(x, pts[1].Y, pts[1].Z, pts[1].W);
                for (int i = 0; i < pta.Length; i++)
                {
                    pta[i].Transform(m, chart3d, ax, this, cl);
                }
                g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
            }

            // Add y ticks:
            offset = (ax.XMax - ax.XMin) / 30.0f;
            ticklength = offset;
            for (float y = ax.YMin; y <= ax.YMax; y = y + ax.YTick)
            {
                pts = CoordinatesOfChartBox(ax, va); ;
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth < 0)
                        ticklength = -offset;
                }
                else if (va.Elevation < 0)
                {
                    if (va.Azimuth >= 0 && va.Azimuth < 180)
                        ticklength = -offset;
                }
                pta[0] = new Point3(pts[1].X + ticklength, y, pts[1].Z, pts[1].W);
                pta[1] = new Point3(pts[1].X, y, pts[1].Z, pts[1].W);
                for (int i = 0; i < pta.Length; i++)
                {
                    pta[i].Transform(m, chart3d, ax, this, cl);
                }
                g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
            }

            float xoffset = (ax.XMax - ax.XMin) / 45.0f;
            float yoffset = (ax.YMax - ax.YMin) / 20.0f;
            float xticklength = xoffset;
            float yticklength = yoffset;
            for (float z = ax.ZMin; z <= ax.ZMax; z = z + ax.ZTick)
            {
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth < -90)
                    {
                        xticklength = 0;
                        yticklength = yoffset;
                    }
                    else if (va.Azimuth >= -90 && va.Azimuth < 0)
                    {
                        xticklength = xoffset;
                        yticklength = 0;
                    }
                    else if (va.Azimuth >= 0 && va.Azimuth < 90)
                    {
                        xticklength = 0;
                        yticklength = -yoffset;
                    }
                    else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                    {
                        xticklength = -xoffset;
                        yticklength = 0;
                    }
                }
                else if (va.Elevation < 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth < -90)
                    {
                        yticklength = 0;
                        xticklength = xoffset;
                    }
                    else if (va.Azimuth >= -90 && va.Azimuth < 0)
                    {
                        yticklength = -yoffset;
                        xticklength = 0;
                    }
                    else if (va.Azimuth >= 0 && va.Azimuth < 90)
                    {
                        yticklength = 0;
                        xticklength = -xoffset;
                    }
                    else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                    {
                        yticklength = yoffset;
                        xticklength = 0;
                    }
                }
                pta[0] = new Point3(pts[2].X, pts[2].Y, z, pts[2].W);
                pta[1] = new Point3(pts[2].X + yticklength,
                    pts[2].Y + xticklength, z, pts[2].W);
                for (int i = 0; i < pta.Length; i++)
                {
                    pta[i].Transform(m, chart3d, ax, this, cl);
                }
                g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
            }
            aPen.Dispose();
        }
        private void AddLabels(Graphics g, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            Point3 pt = new Point3();
            Point3[] pts = CoordinatesOfChartBox(ax, va);
            SolidBrush aBrush = new SolidBrush(cl.LabelFontColor);
            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;

            // Add x tick labels:
            float offset = (ax.YMax - ax.YMin) / 20;
            float labelSpace = offset;
            for (float x = ax.XMin + ax.XTick; x < ax.XMax; x = x + ax.XTick)
            {
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -90 && va.Azimuth < 90)
                        labelSpace = -offset;
                }
                else if (va.Elevation < 0)
                {
                    if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                        va.Azimuth >= 90 && va.Azimuth <= 180)
                        labelSpace = -offset;
                }
                pt = new Point3(x, pts[1].Y + labelSpace, pts[1].Z, pts[1].W);
                pt.Transform(m, chart3d, ax, this, cl);
                g.DrawString(x.ToString(), cl.TickFont, aBrush,
                    new PointF(pt.X, pt.Y), sf);
            }

            // Add y tick labels:
            offset = (ax.XMax - ax.XMin) / 20;
            labelSpace = offset;
            for (float y = ax.YMin + ax.YTick; y < ax.YMax; y = y + ax.YTick)
            {
                pts = CoordinatesOfChartBox(ax, va);
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth < 0)
                        labelSpace = -offset;
                }
                else if (va.Elevation < 0)
                {
                    if (va.Azimuth >= 0 && va.Azimuth < 180)
                        labelSpace = -offset;
                }
                pt = new Point3(pts[1].X + labelSpace, y, pts[1].Z, pts[1].W);
                pt.Transform(m, chart3d, ax, this, cl);
                g.DrawString(y.ToString(), cl.TickFont, aBrush,
                    new PointF(pt.X, pt.Y), sf);

            }

            // Add z tick labels:
            float xoffset = (ax.XMax - ax.XMin) / 30.0f;
            float yoffset = (ax.YMax - ax.YMin) / 15.0f;
            float xlabelSpace = xoffset;
            float ylabelSpace = yoffset;
            SizeF s = g.MeasureString("A", cl.TickFont);
            for (float z = ax.ZMin; z <= ax.ZMax; z = z + ax.ZTick)
            {
                sf.Alignment = StringAlignment.Far;
                pts = CoordinatesOfChartBox(ax, va);
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth < -90)
                    {
                        xlabelSpace = 0;
                        ylabelSpace = yoffset;
                    }
                    else if (va.Azimuth >= -90 && va.Azimuth < 0)
                    {
                        xlabelSpace = xoffset;
                        ylabelSpace = 0;
                    }
                    else if (va.Azimuth >= 0 && va.Azimuth < 90)
                    {
                        xlabelSpace = 0;
                        ylabelSpace = -yoffset;
                    }
                    else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                    {
                        xlabelSpace = -xoffset;
                        ylabelSpace = 0;
                    }
                }
                else if (va.Elevation < 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth < -90)
                    {
                        ylabelSpace = 0;
                        xlabelSpace = xoffset;
                    }
                    else if (va.Azimuth >= -90 && va.Azimuth < 0)
                    {
                        ylabelSpace = -yoffset;
                        xlabelSpace = 0;
                    }
                    else if (va.Azimuth >= 0 && va.Azimuth < 90)
                    {
                        ylabelSpace = 0;
                        xlabelSpace = -xoffset;
                    }
                    else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                    {
                        ylabelSpace = yoffset;
                        xlabelSpace = 0;
                    }
                }

                pt = new Point3(pts[2].X + ylabelSpace,
                    pts[2].Y + xlabelSpace, z, pts[2].W);
                pt.Transform(m, chart3d, ax, this, cl);
                g.DrawString(z.ToString(), cl.TickFont, aBrush,
                    new PointF(pt.X - labelSpace, pt.Y - s.Height / 2), sf);
            }

            // Add Title:
            sf.Alignment = StringAlignment.Center;
            aBrush = new SolidBrush(cl.TitleColor);
            if (cl.Title != "No Title")
            {
                g.DrawString(cl.Title, cl.TitleFont, aBrush,
                    new PointF(chart3d.Width / 2, chart3d.Height / 30), sf);
            }
            aBrush.Dispose();

            // Add x axis label:
            offset = (ax.YMax - ax.YMin) / 3;
            labelSpace = offset;
            sf.Alignment = StringAlignment.Center;
            aBrush = new SolidBrush(cl.LabelFontColor);
            float offset1 = (ax.XMax - ax.XMin) / 10;
            float xc = offset1;
            if (va.Elevation >= 0)
            {
                if (va.Azimuth >= -90 && va.Azimuth < 90)
                    labelSpace = -offset;
                if (va.Azimuth >= 0 && va.Azimuth <= 180)
                    xc = -offset1;
            }
            else if (va.Elevation < 0)
            {
                if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                    va.Azimuth >= 90 && va.Azimuth <= 180)
                    labelSpace = -offset;
                if (va.Azimuth >= -180 && va.Azimuth <= 0)
                    xc = -offset1;
            }
            Point3[] pta = new Point3[2];
            pta[0] = new Point3(ax.XMin, pts[1].Y + labelSpace, pts[1].Z, pts[1].W);
            pta[1] = new Point3((ax.XMin + ax.XMax) / 2 - xc, pts[1].Y + labelSpace,
                pts[1].Z, pts[1].W);
            pta[0].Transform(m, chart3d, ax, this, cl);
            pta[1].Transform(m, chart3d, ax, this, cl);
            float theta = (float)Math.Atan((pta[1].Y - pta[0].Y) / (pta[1].X - pta[0].X));
            theta = theta * 180 / (float)Math.PI;
            GraphicsState gs = g.Save();
            g.TranslateTransform(pta[1].X, pta[1].Y);
            g.RotateTransform(theta);
            g.DrawString(cl.XLabel, cl.LabelFont, aBrush,
                new PointF(0, 0), sf);
            g.Restore(gs);

            // Add y axis label:
            offset = (ax.XMax - ax.XMin) / 3;
            offset1 = (ax.YMax - ax.YMin) / 5;
            labelSpace = offset;
            float yc = ax.YTick;
            if (va.Elevation >= 0)
            {
                if (va.Azimuth >= -180 && va.Azimuth < 0)
                    labelSpace = -offset;
                if (va.Azimuth >= -90 && va.Azimuth <= 90)
                    yc = -offset1;
            }
            else if (va.Elevation < 0)
            {
                yc = -offset1;
                if (va.Azimuth >= 0 && va.Azimuth < 180)
                    labelSpace = -offset;
                if (va.Azimuth >= -90 && va.Azimuth <= 90)
                    yc = offset1;
            }
            pta[0] = new Point3(pts[1].X + labelSpace, ax.YMin, pts[1].Z, pts[1].W);
            pta[1] = new Point3(pts[1].X + labelSpace, (ax.YMin +
                ax.YMax) / 2 + yc, pts[1].Z, pts[1].W);
            pta[0].Transform(m, chart3d, ax, this, cl);
            pta[1].Transform(m, chart3d, ax, this, cl);
            theta = (float)Math.Atan((pta[1].Y - pta[0].Y) / (pta[1].X - pta[0].X));
            theta = theta * 180 / (float)Math.PI;
            gs = g.Save();
            g.TranslateTransform(pta[1].X, pta[1].Y);
            g.RotateTransform(theta);
            g.DrawString(cl.YLabel, cl.LabelFont, aBrush,
                new PointF(0, 0), sf);
            g.Restore(gs);

            // Add z axis labels:
            float zticklength = 10;
            labelSpace = -1.3f * offset;
            offset1 = (ax.ZMax - ax.ZMin) / 8;
            float zc = -offset1;
            for (float z = ax.ZMin; z < ax.ZMax; z = z + ax.ZTick)
            {
                SizeF size = g.MeasureString(z.ToString(), cl.TickFont);
                if (zticklength < size.Width)
                    zticklength = size.Width;
            }
            float zlength = -zticklength;
            if (va.Elevation >= 0)
            {
                if (va.Azimuth >= -180 && va.Azimuth < -90)
                {
                    zlength = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc = -offset1;
                }
                else if (va.Azimuth >= -90 && va.Azimuth < 0)
                {
                    zlength = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc = offset1;
                }
                else if (va.Azimuth >= 0 && va.Azimuth < 90)
                {
                    zlength = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc = -offset1;
                }
                else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                {
                    zlength = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc = offset1;
                }
            }
            else if (va.Elevation < 0)
            {
                if (va.Azimuth >= -180 && va.Azimuth < -90)
                {
                    zlength = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc = offset1;
                }
                else if (va.Azimuth >= -90 && va.Azimuth < 0)
                {
                    zlength = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc = -offset1;
                }
                else if (va.Azimuth >= 0 && va.Azimuth < 90)
                {
                    zlength = zticklength;
                    labelSpace = 2 * offset / 3;
                    zc = offset1;
                }
                else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                {
                    zlength = -zticklength;
                    labelSpace = -1.3f * offset;
                    zc = -offset1;
                }
            }
            pta[0] = new Point3(pts[2].X - labelSpace, pts[2].Y,
                (ax.ZMin + ax.ZMax) / 2 + zc, pts[2].W);
            pta[0].Transform(m, chart3d, ax, this, cl);
            gs = g.Save();
            g.TranslateTransform(pta[0].X - zlength, pta[0].Y);
            g.RotateTransform(270);
            g.DrawString(cl.ZLabel, cl.LabelFont, aBrush,
                new PointF(0, 0), sf);
            g.Restore(gs);
        }
        private void AddGrids(Graphics g, Axes ax, ViewAngle va, Grid gd, ChartLabels cl)
        {
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            Point3[] pta = new Point3[3];
            Point3[] pts = CoordinatesOfChartBox(ax, va);
            Pen aPen = new Pen(gd.GridStyle.LineColor, gd.GridStyle.Thickness);
            aPen.DashStyle = gd.GridStyle.Pattern;

            // Draw x gridlines:
            if (gd.IsXGrid)
            {
                for (float x = ax.XMin; x <= ax.XMax; x = x + ax.XTick)
                {
                    pts = CoordinatesOfChartBox(ax, va);
                    pta[0] = new Point3(x, pts[1].Y, pts[1].Z, pts[1].W);
                    if (va.Elevation >= 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(x, pts[0].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[0].Y, pts[3].Z, pts[1].W);
                        }
                        else
                        {
                            pta[1] = new Point3(x, pts[2].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[2].Y, pts[3].Z, pts[1].W);

                        }
                    }
                    else if (va.Elevation < 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(x, pts[2].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[2].Y, pts[3].Z, pts[1].W);

                        }
                        else
                        {
                            pta[1] = new Point3(x, pts[0].Y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(x, pts[0].Y, pts[3].Z, pts[1].W);
                        }
                    }
                    for (int i = 0; i < pta.Length; i++)
                    {
                        pta[i].Transform(m, chart3d, ax, this, cl);
                    }
                    g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(aPen, pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }
            // Draw y gridlines:
            if (gd.IsYGrid)
            {
                for (float y = ax.YMin; y <= ax.YMax; y = y + ax.YTick)
                {
                    pts = CoordinatesOfChartBox(ax, va);
                    pta[0] = new Point3(pts[1].X, y, pts[1].Z, pts[1].W);
                    if (va.Elevation >= 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[2].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[2].X, y, pts[3].Z, pts[1].W);
                        }
                        else
                        {
                            pta[1] = new Point3(pts[0].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, y, pts[3].Z, pts[1].W);
                        }
                    }
                    if (va.Elevation < 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[0].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, y, pts[3].Z, pts[1].W);

                        }
                        else
                        {
                            pta[1] = new Point3(pts[2].X, y, pts[1].Z, pts[1].W);
                            pta[2] = new Point3(pts[2].X, y, pts[3].Z, pts[1].W);
                        }
                    }
                    for (int i = 0; i < pta.Length; i++)
                    {
                        pta[i].Transform(m, chart3d, ax, this, cl);
                    }
                    g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(aPen, pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }

            // Draw Z gridlines:
            if (gd.IsZGrid)
            {
                for (float z = ax.ZMin; z <= ax.ZMax; z = z + ax.ZTick)
                {
                    pts = CoordinatesOfChartBox(ax, va);
                    pta[0] = new Point3(pts[2].X, pts[2].Y, z, pts[2].W);
                    if (va.Elevation >= 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[2].X, pts[0].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[0].Y, z, pts[1].W);
                        }
                        else
                        {
                            pta[1] = new Point3(pts[0].X, pts[2].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[1].Y, z, pts[1].W);
                        }
                    }
                    if (va.Elevation < 0)
                    {
                        if ((va.Azimuth >= -180 && va.Azimuth < -90) ||
                            (va.Azimuth >= 0 && va.Azimuth < 90))
                        {
                            pta[1] = new Point3(pts[0].X, pts[2].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[0].Y, z, pts[1].W);

                        }
                        else
                        {
                            pta[1] = new Point3(pts[2].X, pts[0].Y, z, pts[1].W);
                            pta[2] = new Point3(pts[0].X, pts[0].Y, z, pts[1].W);
                        }
                    }
                    for (int i = 0; i < pta.Length; i++)
                    {
                        pta[i].Transform(m, chart3d, ax, this, cl);
                    }
                    g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                    g.DrawLine(aPen, pta[1].X, pta[1].Y, pta[2].X, pta[2].Y);
                }
            }
        }
Beispiel #6
0
        private void AddXYColor(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            SolidBrush aBrush = new SolidBrush(Color.White);
            PointF[] pta = new PointF[4];
            Point3[,] pts = ds.PointArray;
            Matrix3 m = new Matrix3();

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();

            // Draw surface on the XY plane:
            if (!IsInterp)
            {
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts.GetLength(1) - 1; j++)
                    {
                        pta[0] = cs2d.Point2D(new PointF(pts[i, j].X, pts[i, j].Y), ax);
                        pta[1] = cs2d.Point2D(new PointF(pts[i, j + 1].X, pts[i, j + 1].Y), ax);
                        pta[2] = cs2d.Point2D(new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y), ax);
                        pta[3] = cs2d.Point2D(new PointF(pts[i + 1, j].X, pts[i + 1, j].Y), ax);
                        Color color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        g.FillPolygon(aBrush, pta);
                        if (ds.LineStyle.IsVisible)
                        {
                            g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }

            // Draw refined surface:
            else if (IsInterp)
            {
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts.GetLength(1) - 1; j++)
                    {
                        Point3[] points = new Point3[4];

                        points[0] = pts[i, j];
                        points[1] = pts[i, j + 1];
                        points[2] = pts[i + 1, j + 1];
                        points[3] = pts[i + 1, j];

                        Interp(g, cs, cs2d, m, points, zmin, zmax, 2, ax, va, cl);

                        pta[0] = cs2d.Point2D(new PointF(pts[i, j].X, pts[i, j].Y), ax);
                        pta[1] = cs2d.Point2D(new PointF(pts[i, j + 1].X, pts[i, j + 1].Y), ax);
                        pta[2] = cs2d.Point2D(new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y), ax);
                        pta[3] = cs2d.Point2D(new PointF(pts[i + 1, j].X, pts[i + 1, j].Y), ax);

                        if (ds.LineStyle.IsVisible)
                        {
                            g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }
        }
Beispiel #7
0
 public Point3 Spherical(float r, float theta, float phi)
 {
     Point3 pt = new Point3();
     float snt = (float)Math.Sin(theta * Math.PI / 180);
     float cnt = (float)Math.Cos(theta * Math.PI / 180);
     float snp = (float)Math.Sin(phi * Math.PI / 180);
     float cnp = (float)Math.Cos(phi * Math.PI / 180);
     pt.X = r * snt * cnp;
     pt.Y = r * cnt;
     pt.Z = -r * snt * snp;
     pt.W = 1;
     return pt;
 }
        public void Peak3D(DataSeries ds, Axes ax)
        {
            ax.XMin = -3;
            ax.XMax = 3;
            ax.YMin = -3;
            ax.YMax = 3;
            ax.ZMin = -8;
            ax.ZMax = 8;
            ax.XTick = 1;
            ax.YTick = 1;
            ax.ZTick = 4;

            ds.XDataMin = ax.XMin;
            ds.YDataMin = ax.YMin;
            ds.XSpacing = 0.3f;
            ds.YSpacing = 0.3f;
            ds.XNumber = Convert.ToInt16((ax.XMax - ax.XMin) / ds.XSpacing) + 1;
            ds.YNumber = Convert.ToInt16((ax.YMax - ax.YMin) / ds.YSpacing) + 1;

            Point3[,] pts = new Point3[ds.XNumber, ds.YNumber];
            for (int i = 0; i < ds.XNumber; i++)
            {
                for (int j = 0; j < ds.YNumber; j++)
                {
                    float x = ds.XDataMin + i * ds.XSpacing;
                    float y = ds.YDataMin + j * ds.YSpacing;
                    double zz = 3 * Math.Pow((1 - x), 2) * Math.Exp(-x * x -
                        (y + 1) * (y + 1)) - 10 * (0.2 * x - Math.Pow(x, 3) -
                        Math.Pow(y, 5)) * Math.Exp(-x * x - y * y) -
                        1 / 3 * Math.Exp(-(x + 1) * (x + 1) - y * y);
                    float z = (float)zz;
                    pts[i, j] = new Point3(x, y, z, 1);
                }
            }
            ds.PointArray = pts;
        }
Beispiel #9
0
        private void AddLine(Graphics g, DataSeries ds, ChartStyle cs,
            Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            Point3[] pts = new Point3[ds.PointList.Count];

            // Find zmin and zmax values, then perform transformation on points:
            float zmin = 0;
            float zmax = 0;
            for (int i = 0; i < pts.Length; i++)
            {
                pts[i] = (Point3)ds.PointList[i];
                zmin = Math.Min(zmin, pts[i].Z);
                zmax = Math.Max(zmax, pts[i].Z);
                pts[i].Transform(m, chart3d, ax, cs, cl);
            }

            // Draw line:
            if (ds.LineStyle.IsVisible == true)
            {
                for (int i = 1; i < pts.Length; i++)
                {
                    if (IsColorMap)
                    {
                        Color color = AddColor(cs, pts[i], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawLine(aPen, pts[i - 1].X, pts[i - 1].Y, pts[i].X, pts[i].Y);
                }
            }
            aPen.Dispose();
        }
Beispiel #10
0
        private void AddContour3D(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            Point3[] pta = new Point3[2];
            Point3[,] pts = ds.PointArray;
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();
            float[] zlevels = new float[numberContours];
            for (int i = 0; i < numberContours; i++)
            {
                zlevels[i] = zmin + i * (zmax - zmin) / (numberContours - 1);
            }

            int i0, i1, i2, j0, j1, j2;
            float zratio = 1;
            // Draw contour on the XY plane:
            for (int i = 0; i < pts.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < pts.GetLength(1) - 1; j++)
                {
                    for (int k = 0; k < numberContours; k++)
                    {
                        if (IsColorMap && ChartType != ChartTypeEnum.FillContour &&
                            ChartType != ChartTypeEnum.SurfaceFillContour)
                        {
                            Color color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                            aPen = new Pen(color, ds.LineStyle.Thickness);
                            aPen.DashStyle = ds.LineStyle.Pattern;
                        }

                        // Left triangle:
                        i0 = i;
                        j0 = j;
                        i1 = i;
                        j1 = j + 1;
                        i2 = i + 1;
                        j2 = j + 1;
                        if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X, (1 - zratio) *
                                pts[i0, j0].Y + zratio * pts[i1, j1].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                                (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3((1 - zratio) * pts[i1, j1].X +
                                zratio * pts[i2, j2].X, pts[i1, j1].Y, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[0] = new Point3((1 - zratio) * pts[i0, j0].X +
                                zratio * pts[i2, j2].X, (1 - zratio) * pts[i0, j0].Y +
                                zratio * pts[i2, j2].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                               (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3((1 - zratio) * pts[i1, j1].X +
                                zratio * pts[i2, j2].X, pts[i1, j1].Y, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X, (1 - zratio) *
                                pts[i0, j0].Y + zratio * pts[i1, j1].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[1] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i2, j2].X * zratio, pts[i0, j0].Y * (1 - zratio) +
                                pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }

                        // right triangle:
                        i0 = i;
                        j0 = j;
                        i1 = i + 1;
                        j1 = j;
                        i2 = i + 1;
                        j2 = j + 1;
                        if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i1, j1].X * zratio, pts[i0, j0].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                                (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3(pts[i1, j1].X, pts[i1, j1].Y *
                                (1 - zratio) + pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z) &&
                            (zlevels[k] >= pts[i1, j1].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i1, j1].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i2, j2].X * zratio, pts[i0, j0].Y * (1 - zratio) +
                                pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i1, j1].Z) /
                                (pts[i2, j2].Z - pts[i1, j1].Z);
                            pta[1] = new Point3(pts[i1, j1].X, pts[i1, j1].Y *
                                (1 - zratio) + pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                        else if ((zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i1, j1].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i1, j1].Z) &&
                            (zlevels[k] >= pts[i0, j0].Z && zlevels[k] < pts[i2, j2].Z ||
                            zlevels[k] < pts[i0, j0].Z && zlevels[k] >= pts[i2, j2].Z))
                        {
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i1, j1].Z - pts[i0, j0].Z);
                            pta[0] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i1, j1].X * zratio, pts[i0, j0].Y, ax.ZMin, 1);
                            zratio = (zlevels[k] - pts[i0, j0].Z) /
                                (pts[i2, j2].Z - pts[i0, j0].Z);
                            pta[1] = new Point3(pts[i0, j0].X * (1 - zratio) +
                                pts[i2, j2].X * zratio, pts[i0, j0].Y * (1 - zratio) +
                                pts[i2, j2].Y * zratio, ax.ZMin, 1);
                            pta[0].Transform(m, chart3d, ax, cs, cl);
                            pta[1].Transform(m, chart3d, ax, cs, cl);
                            g.DrawLine(aPen, pta[0].X, pta[0].Y, pta[1].X, pta[1].Y);
                        }
                    }
                }
            }
            aPen.Dispose();
        }
Beispiel #11
0
 private Color AddColor(ChartStyle cs, Point3 pt, float zmin, float zmax,
     Axes ax, ViewAngle va, ChartLabels cl)
 {
     int colorLength = CMap.GetLength(0);
     int cindex = (int)Math.Round((colorLength * (pt.Z - zmin) +
                 (zmax - pt.Z)) / (zmax - zmin));
     if (cindex < 1)
         cindex = 1;
     if (cindex > colorLength)
         cindex = colorLength;
     Color color = Color.FromArgb(CMap[cindex - 1, 0],
         CMap[cindex - 1, 1], CMap[cindex - 1, 2],
         CMap[cindex - 1, 3]);
     return color;
 }
Beispiel #12
0
        public void AddColorBar(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            if (cs.IsColorBar && IsColorMap)
            {
                Pen aPen = new Pen(Color.Black, 1);
                SolidBrush aBrush = new SolidBrush(cl.TickFontColor);
                StringFormat sFormat = new StringFormat();
                sFormat.Alignment = StringAlignment.Near;
                SizeF size = g.MeasureString("A", cl.TickFont);

                int x, y, width, height;
                Point3[] pts = new Point3[64];
                PointF[] pta = new PointF[4];
                float zmin, zmax;
                if (ChartType == ChartTypeEnum.Slice)
                {
                    zmin = ds.VDataMin();
                    zmax = ds.VDataMax();
                }
                else
                {
                    zmin = ds.ZDataMin();
                    zmax = ds.ZDataMax();
                }
                float dz = (zmax - zmin) / 63;
                if (ChartType == ChartTypeEnum.Contour ||
                    ChartType == ChartTypeEnum.FillContour ||
                    ChartType == ChartTypeEnum.XYColor)
                {
                    x = 5 * cs2d.ChartArea.Width / 6;
                    y = cs2d.PlotArea.Y;
                    width = cs2d.ChartArea.Width / 25;
                    height = cs2d.PlotArea.Height;
                    // Add color bar:
                    for (int i = 0; i < 64; i++)
                    {
                        pts[i] = new Point3(x, y, zmin + i * dz, 1);
                    }
                    for (int i = 0; i < 63; i++)
                    {
                        Color color = AddColor(cs, pts[i], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        float y1 = y + height - (pts[i].Z - zmin) * height / (zmax - zmin);
                        float y2 = y + height - (pts[i + 1].Z - zmin) * height / (zmax - zmin);
                        pta[0] = new PointF(x, y2);
                        pta[1] = new PointF(x + width, y2);
                        pta[2] = new PointF(x + width, y1);
                        pta[3] = new PointF(x, y1);
                        g.FillPolygon(aBrush, pta);
                    }
                    g.DrawRectangle(aPen, x, y, width, height);

                    // Add ticks and labels to the color bar:
                    float ticklength = 0.1f * width;
                    for (float z = zmin; z <= zmax; z = z + (zmax - zmin) / 6)
                    {
                        float yy = y + height - (z - zmin) * height / (zmax - zmin);
                        g.DrawLine(aPen, x, yy, x + ticklength, yy);
                        g.DrawLine(aPen, x + width, yy, x + width - ticklength, yy);
                        g.DrawString((Math.Round(z, 2)).ToString(), cl.TickFont, Brushes.Black,
                            new PointF(x + width + 5, yy - size.Height / 2), sFormat);
                    }
                }
                else
                {
                    x = 5 * cs2d.ChartArea.Width / 6;
                    y = cs2d.ChartArea.Height / 10;
                    width = cs2d.ChartArea.Width / 25;
                    height = 8 * cs2d.ChartArea.Height / 10;

                    // Add color bar:
                    for (int i = 0; i < 64; i++)
                    {
                        pts[i] = new Point3(x, y, zmin + i * dz, 1);
                    }
                    for (int i = 0; i < 63; i++)
                    {
                        Color color = AddColor(cs, pts[i], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        float y1 = y + height - (pts[i].Z - zmin) * height / (zmax - zmin);
                        float y2 = y + height - (pts[i + 1].Z - zmin) * height / (zmax - zmin);
                        pta[0] = new PointF(x, y2);
                        pta[1] = new PointF(x + width, y2);
                        pta[2] = new PointF(x + width, y1);
                        pta[3] = new PointF(x, y1);
                        g.FillPolygon(aBrush, pta);
                    }
                    g.DrawRectangle(aPen, x, y, width, height);

                    // Add ticks and labels to the color bar:
                    float ticklength = 0.1f * width;
                    for (float z = zmin; z <= zmax; z = z + (zmax - zmin) / 6)
                    {
                        float yy = y + height - (z - zmin) * height / (zmax - zmin);
                        g.DrawLine(aPen, x, yy, x + ticklength, yy);
                        g.DrawLine(aPen, x + width, yy, x + width - ticklength, yy);
                        g.DrawString((Math.Round(z, 2)).ToString(), cl.TickFont, Brushes.Black,
                            new PointF(x + width + 5, yy - size.Height / 2), sFormat);
                    }
                }
            }
        }
Beispiel #13
0
        private void Interp(Graphics g, ChartStyle cs, ChartStyle2D cs2d, Matrix3 m,
            Point3[] pta, float zmin, float zmax, int flag, Axes ax,
            ViewAngle va, ChartLabels cl)
        {
            SolidBrush aBrush = new SolidBrush(Color.Black);
            PointF[] points = new PointF[4];
            int npoints = NumberInterp;
            Point3[,] pts = new Point3[npoints + 1, npoints + 1];
            Point3[,] pts1 = new Point3[npoints + 1, npoints + 1];
            float x0 = pta[0].X;
            float y0 = pta[0].Y;
            float x1 = pta[2].X;
            float y1 = pta[2].Y;
            float dx = (x1 - x0) / npoints;
            float dy = (y1 - y0) / npoints;
            float C00 = pta[0].Z;
            float C10 = pta[3].Z;
            float C11 = pta[2].Z;
            float C01 = pta[1].Z;
            float x, y, C;
            Color color;

            if (flag == 1) // For Surface chart
            {
                for (int i = 0; i <= npoints; i++)
                {
                    x = x0 + i * dx;
                    for (int j = 0; j <= npoints; j++)
                    {
                        y = y0 + j * dy;
                        C = (y1 - y) * ((x1 - x) * C00 +
                            (x - x0) * C10) / (x1 - x0) / (y1 - y0) +
                            (y - y0) * ((x1 - x) * C01 +
                            (x - x0) * C11) / (x1 - x0) / (y1 - y0);
                        pts[i, j] = new Point3(x, y, C, 1);
                        pts[i, j].Transform(m, chart3d, ax, cs, cl);
                    }
                }

                for (int i = 0; i < npoints; i++)
                {
                    for (int j = 0; j < npoints; j++)
                    {

                        color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        points[0] = new PointF(pts[i, j].X, pts[i, j].Y);
                        points[1] = new PointF(pts[i + 1, j].X, pts[i + 1, j].Y);
                        points[2] = new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y);
                        points[3] = new PointF(pts[i, j + 1].X, pts[i, j + 1].Y);
                        g.FillPolygon(aBrush, points);
                        aBrush.Dispose();
                    }
                }
            }
            else if (flag == 2) // For XYColor chart
            {
                for (int i = 0; i <= npoints; i++)
                {
                    x = x0 + i * dx;
                    for (int j = 0; j <= npoints; j++)
                    {
                        y = y0 + j * dy;
                        C = (y1 - y) * ((x1 - x) * C00 +
                            (x - x0) * C10) / (x1 - x0) / (y1 - y0) +
                            (y - y0) * ((x1 - x) * C01 +
                            (x - x0) * C11) / (x1 - x0) / (y1 - y0);
                        pts[i, j] = new Point3(x, y, C, 1);
                    }
                }

                for (int i = 0; i < npoints; i++)
                {
                    for (int j = 0; j < npoints; j++)
                    {

                        color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        points[0] = cs2d.Point2D(new PointF(pts[i, j].X, pts[i, j].Y), ax);
                        points[1] = cs2d.Point2D(new PointF(pts[i + 1, j].X, pts[i + 1, j].Y), ax);
                        points[2] = cs2d.Point2D(new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y), ax);
                        points[3] = cs2d.Point2D(new PointF(pts[i, j + 1].X, pts[i, j + 1].Y), ax);
                        g.FillPolygon(aBrush, points);
                        aBrush.Dispose();
                    }
                }
            }
            else if (flag == 3)  // For XYColor3D chart
            {
                for (int i = 0; i <= npoints; i++)
                {
                    x = x0 + i * dx;
                    for (int j = 0; j <= npoints; j++)
                    {
                        y = y0 + j * dy;
                        C = (y1 - y) * ((x1 - x) * C00 +
                            (x - x0) * C10) / (x1 - x0) / (y1 - y0) +
                            (y - y0) * ((x1 - x) * C01 +
                            (x - x0) * C11) / (x1 - x0) / (y1 - y0);
                        pts1[i, j] = new Point3(x, y, C, 1);
                        pts[i, j] = new Point3(x, y, ax.ZMin, 1);
                        pts[i, j].Transform(m, chart3d, ax, cs, cl);
                    }
                }

                for (int i = 0; i < npoints; i++)
                {
                    for (int j = 0; j < npoints; j++)
                    {

                        color = AddColor(cs, pts1[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        points[0] = new PointF(pts[i, j].X, pts[i, j].Y);
                        points[1] = new PointF(pts[i + 1, j].X, pts[i + 1, j].Y);
                        points[2] = new PointF(pts[i + 1, j + 1].X, pts[i + 1, j + 1].Y);
                        points[3] = new PointF(pts[i, j + 1].X, pts[i, j + 1].Y);
                        g.FillPolygon(aBrush, points);
                        aBrush.Dispose();
                    }
                }
            }
        }
Beispiel #14
0
        private void DrawBar(Graphics g, DataSeries ds, ChartStyle cs, Matrix3 m,
            Point3 pt, float xlength, float ylength, float zorign, float zmax, float zmin,
            Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            Color color = AddColor(cs, pt, zmin, zmax, ax, va, cl);
            SolidBrush aBrush = new SolidBrush(color);
            Point3[] pts = new Point3[8];
            Point3[] pts1 = new Point3[8];
            Point3[] pt3 = new Point3[4];
            PointF[] pta = new PointF[4];
            pts[0] = new Point3(pt.X - xlength, pt.Y - ylength, zorign, 1);
            pts[1] = new Point3(pt.X - xlength, pt.Y + ylength, zorign, 1);
            pts[2] = new Point3(pt.X + xlength, pt.Y + ylength, zorign, 1);
            pts[3] = new Point3(pt.X + xlength, pt.Y - ylength, zorign, 1);
            pts[4] = new Point3(pt.X + xlength, pt.Y - ylength, pt.Z, 1);
            pts[5] = new Point3(pt.X + xlength, pt.Y + ylength, pt.Z, 1);
            pts[6] = new Point3(pt.X - xlength, pt.Y + ylength, pt.Z, 1);
            pts[7] = new Point3(pt.X - xlength, pt.Y - ylength, pt.Z, 1);

            for (int i = 0; i < pts.Length; i++)
            {
                pts1[i] = new Point3(pts[i].X, pts[i].Y, pts[i].Z, 1);
                pts[i].Transform(m, chart3d, ax, cs, cl);
            }

            int[] nconfigs = new int[8];
            if (ds.BarStyle.IsBarSingleColor)
            {
                pta[0] = new PointF(pts[4].X, pts[4].Y);
                pta[1] = new PointF(pts[5].X, pts[5].Y);
                pta[2] = new PointF(pts[6].X, pts[6].Y);
                pta[3] = new PointF(pts[7].X, pts[7].Y);
                g.FillPolygon(aBrush, pta);
                g.DrawPolygon(aPen, pta);
                pta[0] = new PointF(pts[0].X, pts[0].Y);
                pta[1] = new PointF(pts[1].X, pts[1].Y);
                pta[2] = new PointF(pts[2].X, pts[2].Y);
                pta[3] = new PointF(pts[3].X, pts[3].Y);
                g.FillPolygon(aBrush, pta);
                g.DrawPolygon(aPen, pta);

                if (va.Azimuth >= -180 && va.Azimuth < -90)
                {
                    nconfigs = new int[8] { 1, 2, 5, 6, 1, 0, 7, 6 };
                }
                else if (va.Azimuth >= -90 && va.Azimuth < 0)
                {
                    nconfigs = new int[8] { 1, 0, 7, 6, 0, 3, 4, 7 };
                }
                else if (va.Azimuth >= 0 && va.Azimuth < 90)
                {
                    nconfigs = new int[8] { 0, 3, 4, 7, 2, 3, 4, 5 };
                }
                else if (va.Azimuth >= 90 && va.Azimuth < 180)
                {
                    nconfigs = new int[8] { 2, 3, 4, 5, 1, 2, 5, 6 };
                }
                pta[0] = new PointF(pts[nconfigs[0]].X, pts[nconfigs[0]].Y);
                pta[1] = new PointF(pts[nconfigs[1]].X, pts[nconfigs[1]].Y);
                pta[2] = new PointF(pts[nconfigs[2]].X, pts[nconfigs[2]].Y);
                pta[3] = new PointF(pts[nconfigs[3]].X, pts[nconfigs[3]].Y);
                g.FillPolygon(aBrush, pta);
                g.DrawPolygon(aPen, pta);
                pta[0] = new PointF(pts[nconfigs[4]].X, pts[nconfigs[4]].Y);
                pta[1] = new PointF(pts[nconfigs[5]].X, pts[nconfigs[5]].Y);
                pta[2] = new PointF(pts[nconfigs[6]].X, pts[nconfigs[6]].Y);
                pta[3] = new PointF(pts[nconfigs[7]].X, pts[nconfigs[7]].Y);
                g.FillPolygon(aBrush, pta);
                g.DrawPolygon(aPen, pta);
            }
            else if (!ds.BarStyle.IsBarSingleColor && IsColorMap)
            {
                pta[0] = new PointF(pts[4].X, pts[4].Y);
                pta[1] = new PointF(pts[5].X, pts[5].Y);
                pta[2] = new PointF(pts[6].X, pts[6].Y);
                pta[3] = new PointF(pts[7].X, pts[7].Y);
                g.FillPolygon(aBrush, pta);
                g.DrawPolygon(aPen, pta);
                pta[0] = new PointF(pts[0].X, pts[0].Y);
                pta[1] = new PointF(pts[1].X, pts[1].Y);
                pta[2] = new PointF(pts[2].X, pts[2].Y);
                pta[3] = new PointF(pts[3].X, pts[3].Y);
                color = AddColor(cs, pts[0], zmin, zmax, ax, va, cl);
                aBrush = new SolidBrush(color);
                g.FillPolygon(aBrush, pta);
                g.DrawPolygon(aPen, pta);

                float dz = (zmax - zmin) / 63;
                if (pt.Z < zorign)
                    dz = -dz;
                int nz = (int)((pt.Z - zorign) / dz) + 1;
                if (nz < 1)
                    nz = 1;
                float z = zorign;

                if (va.Azimuth >= -180 && va.Azimuth < -90)
                {
                    nconfigs = new int[4] { 1, 2, 1, 0 };
                }
                else if (va.Azimuth >= -90 && va.Azimuth < 0)
                {
                    nconfigs = new int[4] { 1, 0, 0, 3 };
                }
                else if (va.Azimuth >= 0 && va.Azimuth < 90)
                {
                    nconfigs = new int[4] { 0, 3, 2, 3 };
                }
                else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                {
                    nconfigs = new int[4] { 2, 3, 1, 2 };
                }
                for (int i = 0; i < nz; i++)
                {
                    z = zorign + i * dz;
                    pt3[0] = new Point3(pts1[nconfigs[0]].X, pts1[nconfigs[0]].Y, z, 1);
                    pt3[1] = new Point3(pts1[nconfigs[1]].X, pts1[nconfigs[1]].Y, z, 1);
                    pt3[2] = new Point3(pts1[nconfigs[1]].X, pts1[nconfigs[1]].Y, z + dz, 1);
                    pt3[3] = new Point3(pts1[nconfigs[0]].X, pts1[nconfigs[0]].Y, z + dz, 1);
                    for (int j = 0; j < pt3.Length; j++)
                    {
                        pt3[j].Transform(m, chart3d, ax, cs, cl);
                    }
                    pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                    pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                    pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                    pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                    color = AddColor(cs, pt3[0], zmin, zmax, ax, va, cl);
                    aBrush = new SolidBrush(color);
                    g.FillPolygon(aBrush, pta);
                }
                pt3[0] = new Point3(pts1[nconfigs[0]].X, pts1[nconfigs[0]].Y, zorign, 1);
                pt3[1] = new Point3(pts1[nconfigs[1]].X, pts1[nconfigs[1]].Y, zorign, 1);
                pt3[2] = new Point3(pts1[nconfigs[1]].X, pts1[nconfigs[1]].Y, pt.Z, 1);
                pt3[3] = new Point3(pts1[nconfigs[0]].X, pts1[nconfigs[0]].Y, pt.Z, 1);
                for (int j = 0; j < pt3.Length; j++)
                {
                    pt3[j].Transform(m, chart3d, ax, cs, cl);
                }
                pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                g.DrawPolygon(aPen, pta);
                for (int i = 0; i < nz; i++)
                {
                    z = zorign + i * dz;
                    pt3[0] = new Point3(pts1[nconfigs[2]].X, pts1[nconfigs[2]].Y, z, 1);
                    pt3[1] = new Point3(pts1[nconfigs[3]].X, pts1[nconfigs[3]].Y, z, 1);
                    pt3[2] = new Point3(pts1[nconfigs[3]].X, pts1[nconfigs[3]].Y, z + dz, 1);
                    pt3[3] = new Point3(pts1[nconfigs[2]].X, pts1[nconfigs[2]].Y, z + dz, 1);
                    for (int j = 0; j < pt3.Length; j++)
                    {
                        pt3[j].Transform(m, chart3d, ax, cs, cl);
                    }
                    pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                    pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                    pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                    pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                    color = AddColor(cs, pt3[0], zmin, zmax, ax, va, cl);
                    aBrush = new SolidBrush(color);
                    g.FillPolygon(aBrush, pta);
                }
                pt3[0] = new Point3(pts1[nconfigs[2]].X, pts1[nconfigs[2]].Y, zorign, 1);
                pt3[1] = new Point3(pts1[nconfigs[3]].X, pts1[nconfigs[3]].Y, zorign, 1);
                pt3[2] = new Point3(pts1[nconfigs[3]].X, pts1[nconfigs[3]].Y, pt.Z, 1);
                pt3[3] = new Point3(pts1[nconfigs[2]].X, pts1[nconfigs[2]].Y, pt.Z, 1);
                for (int j = 0; j < pt3.Length; j++)
                {
                    pt3[j].Transform(m, chart3d, ax, cs, cl);
                }
                pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                g.DrawPolygon(aPen, pta);
            }
            aPen.Dispose();
            aBrush.Dispose();
        }
Beispiel #15
0
        private void AddXYColor3D(Graphics g, DataSeries ds, ChartStyle cs,
            ChartStyle2D cs2d, Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            SolidBrush aBrush = new SolidBrush(Color.White);
            PointF[] pta = new PointF[4];
            Point3[,] pts = ds.PointArray;
            Point3[,] pts1 = new Point3[pts.GetLength(0), pts.GetLength(1)];
            Point3[,] pts2 = new Point3[pts.GetLength(0), pts.GetLength(1)];
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();

            // Perform transformation on points:
            for (int i = 0; i < pts.GetLength(0); i++)
            {
                for (int j = 0; j < pts.GetLength(1); j++)
                {
                    // Make a deep copy the points array:
                    pts1[i, j] = new Point3(pts[i, j].X, pts[i, j].Y, ax.ZMin, 1);
                    pts2[i, j] = new Point3(pts[i, j].X, pts[i, j].Y, ax.ZMin, 1);
                    pts1[i, j].Transform(m, chart3d, ax, cs, cl);
                }
            }

            // Draw surface on the XY plane:
            if (!IsInterp)
            {
                for (int i = 0; i < pts.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts.GetLength(1) - 1; j++)
                    {
                        pta[0] = new PointF(pts1[i, j].X, pts1[i, j].Y);
                        pta[1] = new PointF(pts1[i, j + 1].X, pts1[i, j + 1].Y);
                        pta[2] = new PointF(pts1[i + 1, j + 1].X, pts1[i + 1, j + 1].Y);
                        pta[3] = new PointF(pts1[i + 1, j].X, pts1[i + 1, j].Y);
                        Color color = AddColor(cs, pts[i, j], zmin, zmax, ax, va, cl);
                        aBrush = new SolidBrush(color);
                        g.FillPolygon(aBrush, pta);
                        if (ds.LineStyle.IsVisible)
                        {
                            //g.DrawPolygon(aPen, pta);
                        }
                    }
                }
            }

            // Draw refined surface:
            else if (IsInterp)
            {
                for (int i = 0; i < pts1.GetLength(0) - 1; i++)
                {
                    for (int j = 0; j < pts1.GetLength(1) - 1; j++)
                    {
                        Point3[] points = new Point3[4];
                        points[0] = pts[i, j];
                        points[1] = pts[i, j + 1];
                        points[2] = pts[i + 1, j + 1];
                        points[3] = pts[i + 1, j];
                        Interp(g, cs, cs2d, m, points, zmin, zmax, 3, ax, va, cl);
                    }
                }
            }
        }
Beispiel #16
0
        private Point3[] CoordinatesOfChartBox(Axes ax, ViewAngle va)
        {
            // Create coordinate of the axes:
            Point3[] pta = new Point3[8];
            pta[0] = new Point3(ax.XMax, ax.YMin, ax.ZMin, 1);
            pta[1] = new Point3(ax.XMin, ax.YMin, ax.ZMin, 1);
            pta[2] = new Point3(ax.XMin, ax.YMax, ax.ZMin, 1);
            pta[3] = new Point3(ax.XMin, ax.YMax, ax.ZMax, 1);
            pta[4] = new Point3(ax.XMin, ax.YMin, ax.ZMax, 1);
            pta[5] = new Point3(ax.XMax, ax.YMin, ax.ZMax, 1);
            pta[6] = new Point3(ax.XMax, ax.YMax, ax.ZMax, 1);
            pta[7] = new Point3(ax.XMax, ax.YMax, ax.ZMin, 1);

            Point3[] pts = new Point3[4];
            int[] npts = new int[4] { 0, 1, 2, 3 };
            if (va.Elevation >= 0)
            {
                if (va.Azimuth >= -180 && va.Azimuth < -90)
                {
                    npts = new int[4] { 1, 2, 7, 6 };
                }
                else if (va.Azimuth >= -90 && va.Azimuth < 0)
                {
                    npts = new int[4] { 0, 1, 2, 3 };
                }
                else if (va.Azimuth >= 0 && va.Azimuth < 90)
                {
                    npts = new int[4] { 7, 0, 1, 4 };
                }
                else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                {
                    npts = new int[4] { 2, 7, 0, 5 };
                }
            }
            else if (va.Elevation < 0)
            {
                if (va.Azimuth >= -180 && va.Azimuth < -90)
                {
                    npts = new int[4] { 1, 0, 7, 6 };
                }
                else if (va.Azimuth >= -90 && va.Azimuth < 0)
                {
                    npts = new int[4] { 0, 7, 2, 3 };
                }
                else if (va.Azimuth >= 0 && va.Azimuth < 90)
                {
                    npts = new int[4] { 7, 2, 1, 4 };
                }
                else if (va.Azimuth >= 90 && va.Azimuth <= 180)
                {
                    npts = new int[4] { 2, 1, 0, 5 };
                }

            }

            for (int i = 0; i < 4; i++)
            {
                pts[i] = pta[npts[i]];
            }
            return pts;
        }
        public void SinROverR3D(DataSeries ds, Axes ax)
        {
            ax.XMin = -8;
            ax.XMax = 8;
            ax.YMin = -8;
            ax.YMax = 8;
            ax.ZMin = -0.5f;
            ax.ZMax = 1;
            ax.XTick = 4;
            ax.YTick = 4;
            ax.ZTick = 0.5f;

            ds.XDataMin = ax.XMin;
            ds.YDataMin = ax.YMin;
            ds.XSpacing = 0.5f;
            ds.YSpacing = 0.5f;
            ds.XNumber = Convert.ToInt16((ax.XMax - ax.XMin) / ds.XSpacing) + 1;
            ds.YNumber = Convert.ToInt16((ax.YMax - ax.YMin) / ds.YSpacing) + 1;

            Point3[,] pts = new Point3[ds.XNumber, ds.YNumber];
            for (int i = 0; i < ds.XNumber; i++)
            {
                for (int j = 0; j < ds.YNumber; j++)
                {
                    float x = ds.XDataMin + i * ds.XSpacing;
                    float y = ds.YDataMin + j * ds.YSpacing;
                    float r = (float)Math.Sqrt(x * x + y * y) + 0.000001f;
                    float z = (float)Math.Sin(r) / r;
                    pts[i, j] = new Point3(x, y, z, 1);
                }
            }
            ds.PointArray = pts;
        }
Beispiel #18
0
        private void AddMeshZ(Graphics g, DataSeries ds, ChartStyle cs,
            Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            SolidBrush aBrush = new SolidBrush(Color.White);
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            PointF[] pta = new PointF[4];
            Point3[,] pts = ds.PointArray;
            Point3[,] pts1 = new Point3[pts.GetLength(0), pts.GetLength(1)];
            Color color;

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();

            for (int i = 0; i < pts.GetLength(0); i++)
            {
                for (int j = 0; j < pts.GetLength(1); j++)
                {
                    // Make a deep copy the points array:
                    pts1[i, j] = new Point3(pts[i, j].X, pts[i, j].Y, pts[i, j].Z, 1);
                    // Perform transformations on points:
                    pts[i, j].Transform(m, chart3d, ax, cs, cl);
                }
            }

            for (int i = 0; i < pts.GetLength(0) - 1; i++)
            {
                for (int j = 0; j < pts.GetLength(1) - 1; j++)
                {
                    int ii = i;
                    if (va.Azimuth >= -180 && va.Azimuth < 0)
                    {
                        ii = pts.GetLength(0) - 2 - i;
                    }
                    pta[0] = new PointF(pts[ii, j].X, pts[ii, j].Y);
                    pta[1] = new PointF(pts[ii, j + 1].X, pts[ii, j + 1].Y);
                    pta[2] = new PointF(pts[ii + 1, j + 1].X, pts[ii + 1, j + 1].Y);
                    pta[3] = new PointF(pts[ii + 1, j].X, pts[ii + 1, j].Y);
                    g.FillPolygon(aBrush, pta);
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pts[ii, j], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawPolygon(aPen, pta);
                }
            }

            Point3[] pt3 = new Point3[4];
            for (int i = 0; i < pts1.GetLength(0); i++)
            {
                int jj = pts1.GetLength(0) - 1;
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -90 && va.Azimuth <= 90)
                        jj = 0;
                }
                else if (va.Elevation < 0)
                {
                    jj = 0;
                    if (va.Azimuth >= -90 && va.Azimuth <= 90)
                        jj = pts1.GetLength(0) - 1;
                }

                if (i < pts1.GetLength(0) - 1)
                {
                    pt3[0] = new Point3(pts1[i, jj].X, pts1[i, jj].Y, pts1[i, jj].Z, 1);
                    pt3[1] = new Point3(pts1[i + 1, jj].X, pts1[i + 1, jj].Y, pts1[i + 1, jj].Z, 1);
                    pt3[2] = new Point3(pts1[i + 1, jj].X, pts1[i + 1, jj].Y, ax.ZMin, 1);
                    pt3[3] = new Point3(pts1[i, jj].X, pts1[i, jj].Y, ax.ZMin, 1);
                    for (int k = 0; k < 4; k++)
                        pt3[k].Transform(m, chart3d, ax, cs, cl);
                    pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                    pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                    pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                    pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                    g.FillPolygon(aBrush, pta);
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pt3[0], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawPolygon(aPen, pta);
                }
            }
            for (int j = 0; j < pts1.GetLength(1); j++)
            {
                int ii = 0;
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= 0 && va.Azimuth <= 180)
                        ii = pts1.GetLength(1) - 1;
                }
                else if (va.Elevation < 0)
                {
                    if (va.Azimuth >= -180 && va.Azimuth <= 0)
                        ii = pts1.GetLength(1) - 1;
                }
                if (j < pts1.GetLength(1) - 1)
                {
                    pt3[0] = new Point3(pts1[ii, j].X, pts1[ii, j].Y, pts1[ii, j].Z, 1);
                    pt3[1] = new Point3(pts1[ii, j + 1].X, pts1[ii, j + 1].Y, pts1[ii, j + 1].Z, 1);
                    pt3[2] = new Point3(pts1[ii, j + 1].X, pts1[ii, j + 1].Y, ax.ZMin, 1);
                    pt3[3] = new Point3(pts1[ii, j].X, pts1[ii, j].Y, ax.ZMin, 1);
                    for (int k = 0; k < 4; k++)
                        pt3[k].Transform(m, chart3d, ax, cs, cl);
                    pta[0] = new PointF(pt3[0].X, pt3[0].Y);
                    pta[1] = new PointF(pt3[1].X, pt3[1].Y);
                    pta[2] = new PointF(pt3[2].X, pt3[2].Y);
                    pta[3] = new PointF(pt3[3].X, pt3[3].Y);
                    g.FillPolygon(aBrush, pta);
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pt3[0], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawPolygon(aPen, pta);
                }
            }
            aPen.Dispose();
            aBrush.Dispose();
        }
Beispiel #19
0
 public Point3 Cylindrical(float r, float theta, float y)
 {
     Point3 pt = new Point3();
     float sn = (float)Math.Sin(theta * Math.PI / 180);
     float cn = (float)Math.Cos(theta * Math.PI / 180);
     pt.X = r * cn;
     pt.Y = y;
     pt.Z = -r * sn;
     pt.W = 1;
     return pt;
 }
Beispiel #20
0
 public void AddPoint(Point3 pt)
 {
     PointList.Add(pt);
 }
Beispiel #21
0
 public Point4(Point3 pt3, float v)
 {
     point3 = pt3;
     V = v;
 }
Beispiel #22
0
        private void AddWaterfall(Graphics g, DataSeries ds, ChartStyle cs,
            Axes ax, ViewAngle va, ChartLabels cl)
        {
            Pen aPen = new Pen(ds.LineStyle.LineColor, ds.LineStyle.Thickness);
            aPen.DashStyle = ds.LineStyle.Pattern;
            SolidBrush aBrush = new SolidBrush(Color.White);
            Matrix3 m = Matrix3.AzimuthElevation(va.Elevation, va.Azimuth);
            Point3[,] pts = ds.PointArray;
            Point3[] pt3 = new Point3[pts.GetLength(0) + 2];
            PointF[] pta = new PointF[pts.GetLength(0) + 2];
            Color color;

            // Find the minumum and maximum z values:
            float zmin = ds.ZDataMin();
            float zmax = ds.ZDataMax();

            for (int j = 0; j < pts.GetLength(1); j++)
            {
                int jj = j;
                if (va.Elevation >= 0)
                {
                    if (va.Azimuth >= -90 && va.Azimuth < 90)
                    {
                        jj = pts.GetLength(1) - 1 - j;
                    }
                }
                else if (va.Elevation < 0)
                {
                    jj = pts.GetLength(1) - 1 - j;
                    if (va.Azimuth >= -90 && va.Azimuth < 90)
                    {
                        jj = j;
                    }
                }
                for (int i = 0; i < pts.GetLength(0); i++)
                {
                    pt3[i + 1] = pts[i, jj];
                    if (i == 0)
                    {
                        pt3[0] = new Point3(pt3[i + 1].X, pt3[i + 1].Y, ax.ZMin, 1);
                    }
                    if (i == pts.GetLength(0) - 1)
                    {
                        pt3[pts.GetLength(0) + 1] = new Point3(pt3[i + 1].X,
                            pt3[i + 1].Y, ax.ZMin, 1);
                    }
                }

                for (int i = 0; i < pt3.Length; i++)
                {
                    pt3[i].Transform(m, chart3d, ax, cs, cl);
                    pta[i] = new PointF(pt3[i].X, pt3[i].Y);
                }
                g.FillPolygon(aBrush, pta);

                for (int i = 1; i < pt3.Length; i++)
                {
                    if (IsColorMap)
                    {
                        color = AddColor(cs, pt3[i], zmin, zmax, ax, va, cl);
                        aPen = new Pen(color, ds.LineStyle.Thickness);
                        aPen.DashStyle = ds.LineStyle.Pattern;
                    }
                    g.DrawLine(aPen, pta[i - 1], pta[i]);
                }
            }
            aPen.Dispose();
            aBrush.Dispose();
        }