use patch to plot hexahedron with 20 nodes

4 visualizaciones (últimos 30 días)
alize beemiel
alize beemiel el 13 de Nov. de 2020
Comentada: alize beemiel el 13 de Nov. de 2020
hi
i have a hexaedron with 20 nodes
i have coordonates X Y Z
and the conectivity [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
and the stress value of all nodes TZ
TZ=[ -0.0225
-0.0226
-0.0233
-0.0185
-0.0188
-0.0144
-0.0144
-0.0141
-0.0062
-0.0064
0
0
0
-0.0209
-0.0216
-0.0126
-0.0123
0
0
-0.0137]
how can i use patch to plot my hexaedon and take all nodes to make interpolation for facecolor ith TZ
i use this
patch('Faces',Rectangles,'Vertices',[Vertice(:,1) Vertice(:,2) Vertice(:,3)],'FaceVertexCData',TZ,'FaceColor','interp','Marker','.');
vertice is X Y Z for the hexaedron
TZ is color face
but when i come to determine rectangle or the point to make faces i have problem
i wante to use all points of hexaedre
i do this but it deasnt work
Bricks =[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
Rectangles=[];
Rectangles=[Rectangles ; [Bricks(:,1) Bricks(:,2) Bricks(:,3) Bricks(:,4) Bricks(:,5) Bricks(:,6) Bricks(:,7) Bricks(:,8)]];
Rectangles=[Rectangles ; [Bricks(:,13) Bricks(:,14) Bricks(:,15) Bricks(:,16) Bricks(:,17) Bricks(:,18) Bricks(:,19) Bricks(:,20)]];
Rectangles=[Rectangles ; [Bricks(:,1) Bricks(:,2) Bricks(:,3) Bricks(:,10) Bricks(:,15) Bricks(:,14) Bricks(:,13) Bricks(:,9)]];
Rectangles=[Rectangles ; [Bricks(:,3) Bricks(:,4) Bricks(:,5) Bricks(:,11) Bricks(:,17) Bricks(:,16) Bricks(:,15) Bricks(:,10)]];
Rectangles=[Rectangles ; [Bricks(:,5) Bricks(:,6) Bricks(:,7) Bricks(:,12) Bricks(:,19) Bricks(:,18) Bricks(:,17) Bricks(:,11)]];
Rectangles=[Rectangles ; [Bricks(:,7) Bricks(:,8) Bricks(:,1) Bricks(:,9) Bricks(:,13) Bricks(:,20) Bricks(:,19) Bricks(:,12)]];
some one tell me use rectangle and take just the point of a corner but it give me a wrong resultat
thank you for any help
  2 comentarios
Mario Malic
Mario Malic el 13 de Nov. de 2020
Try to create patch for only one face, once you manage to do it, work your way towards patching all the faces.
alize beemiel
alize beemiel el 13 de Nov. de 2020
ok

Iniciar sesión para comentar.

Respuesta aceptada

Bruno Luong
Bruno Luong el 13 de Nov. de 2020
Editada: Bruno Luong el 13 de Nov. de 2020
Here we go
[x,y,z]=ndgrid(0:2);
xyz = [x(:) y(:) z(:)];
xyz(sum(xyz==1,2)>1,:)=[];
x=xyz(:,1);y=xyz(:,2);z=xyz(:,3);
a=atan2(z-1.001,x-1);
[~,is]=sortrows([y -a]);
xyz=xyz(is,:);
F = zeros(6,8);
i = 0;
for c=1:3
for v=[0 2]
r = find(xyz(:,c)==v);
st = xyz(r,:);
st(:,c) = [];
st = (st-[1 1]);
a = sign(v-1)*atan2(st(:,2),st(:,1));
[~,is] = sort(a);
i = i+1;
F(i,:) = r(is);
end
end
xyz = xyz/2;
% Create a dummy Stress
%Stress = 2-sqrt(sum((xyz-rand(1,3)).^2,2));
TZ=[ -0.0225
-0.0226
-0.0233
-0.0185
-0.0188
-0.0144
-0.0144
-0.0141
-0.0062
-0.0064
0
0
0
-0.0209
-0.0216
-0.0126
-0.0123
0
0
-0.0137];
Stress = abs(TZ);
StressNorm = (Stress-min(Stress))/(max(Stress)-min(Stress));
close all
figure
clmap = jet;
StressColor = interp1(linspace(0,1,size(clmap,1)),clmap,StressNorm,'nearest','extrap');
patch('Faces',F,'Vertices',xyz,'FaceVertexCData',StressColor,'FaceColor','interp');
hold on
%scatter3(xyz(:,1),xyz(:,2),xyz(:,3));
set(gca,'Xtick',[],'Ytick',[],'Ztick',[])
for k=1:size(xyz,1)
text(xyz(k,1),xyz(k,2),xyz(k,3),num2str(k));
end
xlabel('x');
ylabel('y');
zlabel('z');
view(3)
axis('equal');

Más respuestas (0)

Categorías

Más información sobre Stress and Strain en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by