We have tetrahedra mesh we went to extract a sphere from this mesh and adabting the mesh
We do this code, but we found a problem in the output tri
fid = fopen(‘nodes10.dat’);
data = fscanf(fid, ‘%g %g %g’, [3, Inf]);
A = data’;
fclose(fid);
A;
n=size(A);
kk=n(1);
R=1.5;
MM=zeros(kk,1);
for k=1:kk
MM(k)=0;
for i=1:3
MM(k)= MM(k)+ A(k,i)*A(k,i);
end
MM(k)=sqrt(MM(k));
end
M = A(MM >R,:);
[x1,y1,z1] = sphere(1);
Psphere = [R*x1(:) R*y1(:) R*z1(:)];
Psphere = unique(Psphere,’rows’);
P = [M;Psphere];
plot3(P(:,1),P(:,2),P(:,3),’.’)
shp= alphaShape(P(:,1),P(:,2),P(:,3),1);
plot(shp)
shp.Alpha = 2;
[tri,loc] = alphaTriangulation(shp);
fid = fopen(‘nodess.dat’,’w’);
fprintf(fid,’%it %it %in’,loc);
fclose(fid);
fid = fopen(‘tetreades.dat’,’w’);
fprintf(fid,’%it %it %it %in’,tri);
fclose(fid);
numtetrahedra = size(tri,1);
numnodes = size(loc);
% model = createpde;
% [gCube,mshC]=geometryFromMesh(model,loc’,tri’);
% %save (‘nodesn.txt’, ‘tri’)
% tri
% loc;
axis equalWe do this code, but we found a problem in the output tri
fid = fopen(‘nodes10.dat’);
data = fscanf(fid, ‘%g %g %g’, [3, Inf]);
A = data’;
fclose(fid);
A;
n=size(A);
kk=n(1);
R=1.5;
MM=zeros(kk,1);
for k=1:kk
MM(k)=0;
for i=1:3
MM(k)= MM(k)+ A(k,i)*A(k,i);
end
MM(k)=sqrt(MM(k));
end
M = A(MM >R,:);
[x1,y1,z1] = sphere(1);
Psphere = [R*x1(:) R*y1(:) R*z1(:)];
Psphere = unique(Psphere,’rows’);
P = [M;Psphere];
plot3(P(:,1),P(:,2),P(:,3),’.’)
shp= alphaShape(P(:,1),P(:,2),P(:,3),1);
plot(shp)
shp.Alpha = 2;
[tri,loc] = alphaTriangulation(shp);
fid = fopen(‘nodess.dat’,’w’);
fprintf(fid,’%it %it %in’,loc);
fclose(fid);
fid = fopen(‘tetreades.dat’,’w’);
fprintf(fid,’%it %it %it %in’,tri);
fclose(fid);
numtetrahedra = size(tri,1);
numnodes = size(loc);
% model = createpde;
% [gCube,mshC]=geometryFromMesh(model,loc’,tri’);
% %save (‘nodesn.txt’, ‘tri’)
% tri
% loc;
axis equal We do this code, but we found a problem in the output tri
fid = fopen(‘nodes10.dat’);
data = fscanf(fid, ‘%g %g %g’, [3, Inf]);
A = data’;
fclose(fid);
A;
n=size(A);
kk=n(1);
R=1.5;
MM=zeros(kk,1);
for k=1:kk
MM(k)=0;
for i=1:3
MM(k)= MM(k)+ A(k,i)*A(k,i);
end
MM(k)=sqrt(MM(k));
end
M = A(MM >R,:);
[x1,y1,z1] = sphere(1);
Psphere = [R*x1(:) R*y1(:) R*z1(:)];
Psphere = unique(Psphere,’rows’);
P = [M;Psphere];
plot3(P(:,1),P(:,2),P(:,3),’.’)
shp= alphaShape(P(:,1),P(:,2),P(:,3),1);
plot(shp)
shp.Alpha = 2;
[tri,loc] = alphaTriangulation(shp);
fid = fopen(‘nodess.dat’,’w’);
fprintf(fid,’%it %it %in’,loc);
fclose(fid);
fid = fopen(‘tetreades.dat’,’w’);
fprintf(fid,’%it %it %it %in’,tri);
fclose(fid);
numtetrahedra = size(tri,1);
numnodes = size(loc);
% model = createpde;
% [gCube,mshC]=geometryFromMesh(model,loc’,tri’);
% %save (‘nodesn.txt’, ‘tri’)
% tri
% loc;
axis equal sphere in tetrahedra MATLAB Answers — New Questions