How to combine two implicit functions

조회 수: 13 (최근 30일)
Darpan Shidid
Darpan Shidid 2017년 10월 3일
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?
Kamal Uddin Mohammad Miah
Kamal Uddin Mohammad Miah 2021년 9월 1일

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Scalar Volume Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by