Skip to content

adding isosurface functionality to matlab_plotly #413

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

Merged

Conversation

gilbertogalvis
Copy link
Contributor

@gilbertogalvis gilbertogalvis commented Oct 19, 2021

I was working on adding the MATLAB isosurface functionality to matlab_plotly. Issue #386 reports that matlab_plotly does not have support for the isosurface functionality. So I started adding it. Since matlab_plotly did not have support for this functionality, to solve this I had to code everything necessary from scratch. Specifically, I have coded a whole file for this which I have called updateIsosurface.m.
Now, to use this functionality, when invoking fig2plotly it is necessary to set the optional parameter 'TreatAs' to 'isosurface'

Example 1

[x,y,z] = meshgrid([-3:0.25:3]); 
V = x.*exp(-x.^2 -y.^2 -z.^2);
isosurface(x,y,z,V,1e-4);

Screen Shot 2021-10-19 at 8 54 31 AM

Example 2

[x,y,z] = meshgrid([-3:0.25:3]); 
V = x.*exp(-x.^2 -y.^2 -z.^2);
s = isosurface(x,y,z,V,1e-4);
p = patch(s);
isonormals(x,y,z,V,p)
view(3);
set(p,'FaceColor',[0.5 1 0.5]);  
set(p,'EdgeColor','none');
camlight;
lighting gouraud;

Screen Shot 2021-10-19 at 8 55 01 AM

Example 3

[x,y,z] = meshgrid([-3:0.25:3]); 
V = x.*exp(-x.^2 -y.^2 -z.^2);
[faces,verts,colors] = isosurface(x,y,z,V,1e-4,x);
patch('Vertices',verts,'Faces',faces,'FaceVertexCData',colors,...
    'FaceColor','interp','EdgeColor','interp')
view(3) 
colormap copper

Screen Shot 2021-10-19 at 8 55 40 AM

Example 4

[x,y,z,v] = flow;
p = patch(isosurface(x,y,z,v,-3));
isonormals(x,y,z,v,p)
p.FaceColor = 'red';
p.EdgeColor = 'none';
daspect([1 1 1])
view(3); 
axis tight
camlight 
lighting gouraud

Screen Shot 2021-10-19 at 8 56 20 AM

Example 5

[x,y,z,v] = flow; 
[faces,verts,colors] = isosurface(x,y,z,v,-3,x); 
patch('Vertices',verts,'Faces',faces,'FaceVertexCData',colors,...
    'FaceColor','interp','EdgeColor','interp')
view(30,-15)
axis vis3d
colormap copper

Screen Shot 2021-10-19 at 8 56 49 AM

Links to Chart-Studio

https://chart-studio.plotly.com/~galvisgilberto/4654/#/
https://chart-studio.plotly.com/~galvisgilberto/4656/#/
https://chart-studio.plotly.com/~galvisgilberto/4658/#/
https://chart-studio.plotly.com/~galvisgilberto/4660/#/
https://chart-studio.plotly.com/~galvisgilberto/4662/#/

@gilbertogalvis gilbertogalvis merged commit c54dff9 into master Oct 19, 2021
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

Successfully merging this pull request may close these issues.

2 participants