Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how Bounds of surface is set #9

Open
GIRISHBR07 opened this issue Feb 20, 2018 · 5 comments
Open

how Bounds of surface is set #9

GIRISHBR07 opened this issue Feb 20, 2018 · 5 comments

Comments

@GIRISHBR07
Copy link

can you please explain how Bounds of surface is set in the below line:

        Shape surface = Builder.buildOrthonomal(new MyOrthonormalGrid(range, steps, range, steps), new MyMapper());
@benoit74
Copy link
Owner

benoit74 commented Feb 20, 2018

X and Y bounds are computed based on the bounds of the OrthonormalGrid which is passed, i.e. "range" parameters in your sample
Z bounds are computed based on the Mapper transformation. More precisely, the following process occurs :

  • on each coordinates of the grid (i.e. each "angle" since you have an orthonormalGrid), the mapper function is applied to compute z value
  • min and max z values are used as bounds of the surface.
    It is hence very important to ensure that appropriate "steps" values are used to ensure that your surface is plotted correctly (always the same old discretization problem).

@GIRISHBR07
Copy link
Author

GIRISHBR07 commented Feb 20, 2018

thank you for your reply.
I have one more question!
i have passed a Range as 0 to 1. and the below is input source for X values
double[] xval = {
0.0,
0.0,
0.0,
0.0,
0.3,
0.3,
0.3,
0.3,
0.8,
0.8,
0.8,
0.8,
1.0,
1.0,
1.0,
1.0
};
after the execution of below statement
Shape surface = Builder.buildOrthonomal(new MyOrthonormalGrid(range, steps, range, steps), new MyMapper());
min x = 0 and max x is 1 which is correct.
but similiraly when i change input source to below value for the same range
double[] xval = {
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.7,
0.8,
1,
1
};
min and max X,Y,Z are set to -1.7976931348623157E+308 and 1.7976931348623157E+308.
this is causing problem.
can you please the resolve this issue?
this is cas

@benoit74
Copy link
Owner

benoit74 commented Feb 20, 2018 via email

@GIRISHBR07
Copy link
Author

nzy3d-api-master.zip

i have attached file here.
please look into issue.

@benoit74
Copy link
Owner

benoit74 commented Feb 21, 2018

OK, I got your issue.

With nzy3d, you previously had only one solution: you must plot a surface.

And this surface is usually on an orthonormal grid, meaning x and y samples must be regularly spaced AND must form a regular grid. This is absolutely not the case of your data. Hence, all points of your "abnormal" grid are discarded and you end up with an error (which should be way more explicit, I agree).

Now, Martin@jzy3d has implemented a 3D scatter plot (which is probably what you want to do as I image). I just converted it into C# and commited the code in nzy3d repo. You can now plot 3D scatterplots with either a constant color for all points or a choosen color per point (use the Scatter class) or a color relative to their z-value (use ScatterMultiColor class).

One sample code with ScatterMultiColor:

            int size = 10;
            float x;
            float y;
            float z;
            Coord3d[] points = new Coord3d[size];

            // Create scatter points
            Random random = new Random();
            for(int i=0; i<size; i++){
                
                x = (float)random.NextDouble() - 0.5f;
                y = (float)random.NextDouble() - 0.5f;
                z = (float)random.NextDouble() - 0.5f;
                points[i] = new Coord3d(x, y, z);
            }       

            // Create a drawable scatter with a colormap
            ScatterMultiColor scatter = new ScatterMultiColor( points, new ColorMapper( new ColorMapRainbow(), -0.5f, 0.5f ), 5);

            // Create a chart and add scatter
            Chart chart = new Chart(myRenderer3D, Quality.Nicest);
            chart.AxeLayout.MainColor = Color.WHITE;
            chart.View.BackgroundColor = Color.BLACK;
            chart.Scene.Add(scatter);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants