0

I'm realy beginner in C# and i have a little bite difficulty with 3D plot in C#. I have alot of X and Y data points. X and Y for each profil make a 2d plot. I want to get all of profils together in 3d plot with constant steps (z).

I tried to do this with a chart in winform based on this question: How to plot a 3D Graph to represent an object in space

I have to admit, that does not work, like i am expecting. I've seen some programmers, who are using WPF for 3D plot. I did it in wpf through Point3D, but i don't think so, that my strategie on this was proper.

I can show some of my code:

        double y = 1;
        const double s = 0.1;


        for (int i = 0; i <= Profil; i++)
        //for (int i = 0; i < 5; i++)
        {
            try
            {

                for (int j = 0; j <= X[i].Count; j++)
                //for (int j = 0; j < 10; j++)
                {
                    try
                    {

                        Point3D p00 = new Point3D(X[i][j], Y[i][j], z);
                        Point3D p01 = new Point3D(X[i][j + 1], Y[i][j + 1], z);
                        Point3D p02 = new Point3D(X[i + 1][j], Y[i + 1][j], z + s);
                        Point3D p03 = new Point3D(X[i + 1][j + 1], Y[i + 1][j + 1], z + s);



                        // Add the triangles.
                        AddTriangle(mesh, p00, p01, p02);
                        AddTriangle(mesh, p01, p02, p03);


                    }

                    catch { continue; }



                }
                z += s;

            }
            catch { continue; }

        }

X and Y are two dimensional lists. Could somebody help me?

  • How are you organizing the data? Normally you would use a 2D array where the indices represents the position and have a value for each position, like an image. Or have a list/1d array of position-value pairs. A 2D array with XY coordinates seem odd, what does the indices represent? a vector field? – JonasH Jan 28 '21 at 08:55
  • For each profil (2d drawing) there ist data points in this form X[profil][x_vlaues] and Y[profil][y_vlaues] and each list contains the values X and Y for all profils. @JonasH – vendettaa sharlk Jan 28 '21 at 10:38
  • but you used x values in two places there, both as index and as a value, would this hold for all points `X[p][n] == n` ? – JonasH Jan 28 '21 at 10:45
  • No, i just did that to avoid errors, that one profile contains more or less points than the other. @JonasH – vendettaa sharlk Jan 28 '21 at 11:30

0 Answers0