How to combine two implicit functions

3 次查看(过去 30 天)
I want to give thickness to a Gyroid Function for Gyroid is
Gyroid=(cos(x) .* sin(y) + cos(y) .* sin(z) + cos(z) .* sin(x));
% Reverse Gyroid
R=sqrt( (-sin(x).*sin(y)+cos(x).*cos(z)).^2+(-sin(y).*sin(z)+cos(y).*cos(x)).^2+(-sin(z).*sin(x)+cos(z).*cos(y)).^2 );
ReverseGyroid=(Gyroid.*T./R);
isosurface(Gyroid)
isosurface(ReverseGyroid)
This is the output I expect but as one Isosurface def and not by using isosurface separately for both surfaces.
Thank you in advance
  4 个评论
Jim Joy
Jim Joy 2017-10-6
Hi Darpan,
Thank you for clarifying that you would like to fill the space between the two Gyroids.
To clarify further: are you constructing the 'reverse Gyroid' for visualization purposes, or is there a mathematical significance to the space between the Gyroids?
I am asking, because the "isocaps" function might be useful for you. Does the command below give a result similar to what you expect?
isocaps(x,y,z,Gyroid,0)
In general, filling the space between arbitrary surfaces is a bit trickier. The MATLAB Answers post here details one approach for doing so, which I believe could be adapted to this scenario. The basic idea is to create a 3D grid of data in which the value at a point (x,y,z) is the distance to the nearest surface. You can then use "isocaps" to connect the surfaces.
If you would like further suggestions about how to do this, please post your code for generating the 'reverse gyroid'. In particular, please post how to generate the variable 'T'. This will help users on this forum to experiment with ideas that may help provide a more complete solution.
Best Regards,
Jim
Darpan Shidid
Darpan Shidid 2017-10-8
Hi Jim, Yes I want to use ISOCAPS for filling the gap. The code is as supplied in the Question. The var T is just thickness that can be 0.5. Currently if I use the isocaps command it will fill the two isosurfaces separately. I want a thick Gyroid just like the image attached. How can I achieve that using Isocaps? Here is the code again.
Gyroid=(cos(x) .* sin(y) + cos(y) .* sin(z) + cos(z) .* sin(x));
% Reverse Gyroid
R=sqrt( (-sin(x).*sin(y)+cos(x).*cos(z)).^2+(-sin(y).*sin(z)+cos(y).*cos(x)).^2+(-sin(z).*sin(x)+cos(z).*cos(y)).^2 );
ReverseGyroid=(Gyroid.*T./R);
isosurface(Gyroid)
isosurface(ReverseGyroid)

请先登录,再进行评论。

回答(3 个)

Paulo GOMES
Paulo GOMES 2018-12-17
clear all
close all
clc
x_period = 4;
y_period = 4;
z_period = 4;
[x,y,z] = meshgrid(0:0.1:x_period*pi, 0:0.1:y_period*pi, 0:0.1:z_period*pi);
Gyroid=(cos(x) .* sin(y) + cos(y) .* sin(z) + cos(z) .* sin(x));
isosurface(x,y,z,Gyroid)
isocaps(x,y,z,Gyroid,0)
If you do something like this, I think you will get the solution you want!
  1 个评论
Yash Mistry
Yash Mistry 2019-7-4
hi, i am getting the error of too many input arguments for your code(isosurface) in your code. can you help me with it.

请先登录,再进行评论。


Deison Preve
Deison Preve 2019-7-17
hi Yash Mistry, did you manage to do so? I am trying to do same thing.. add some thickness on the TPMS isosurface.. If you did, could you share the lane?

Fabian Günther
Fabian Günther 2020-8-18
The attached code generates a stl file of a Gyroid shell arrangement when you include the stlwrite function.
clc
clear
close all
n=200;
t=pi/n;
x_max=2;
y_max=2;
z_max=2;
xi = 0:t:x_max;
yi = 0:t:y_max;
zi = 0:t:z_max;
[x,y,z] = meshgrid(xi,yi,zi);
ri=-0.35;
ra=-ri;
F=cos(2.*pi.*x).*sin(2.*pi.*y)+cos(2.*pi.*y).*sin(2.*pi.*z)+cos(2.*pi.*z).*sin(2.*pi.*x);
F=-(F+ri).*(F+ra);
[fs,v]=isosurface(x,y,z,F,0);
[fc,v2,c] = isocaps(x,y,z,F,0);
fn = [fs ; fc+length(v(:,1))];
vn = [v ; v2];
stlwrite('geometry.stl',fn,vn);
  2 个评论
NickKnack CAD
NickKnack CAD 2021-7-1
hi @Fabian Günther your code just happens to be what ive been searching for.
Could you please provide a small explanation of whats in the last part of your code after the gyroid surface gets offset to just above the WRITESTL statement?

请先登录,再进行评论。

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by