Patch: Problem using FaceVertexAlphaData to control face visibility
조회 수: 6 (최근 30일)
이전 댓글 표시
Hello!
As part of a larger topology optimization algotihm i have written a plot function. This plot function visualizes a 3D matrix containing values between 0-1. Where each value represent the 'artificial density' of a cube.
I have been using the patch function to draw the faces of the cubes. Previously i was able to use the FaceVertexAlphaData option to just plot the faces of the cubes with a density higher then 0.3.
I did not touch my code for two months, and now using it again my plotting function is not plotting the right transparency for the faces and edges anymore.
This is an example of a result i was getting previously:

And this is the result i am currently getting:

I am using r2022b and did not make any changes to my code. What could be the reason I am not getting the same result anymore? And does anyone have any suggestions how i could achieve the same result i was previously getting without the use of a loop?
Thank you very much in advance!
This is the relevant snippet of my code:
%setup face matrix
A = (0:8:(nele_L-1)*8);
B = repmat(reshape(repmat(A, 6, 1), [nele_L*6, 1]), 1, 4);
face_mat = [1 2 3 4; 2 6 7 3; 6 5 8 7; 5 1 4 8; 1 2 6 5; 4 3 7 8]; %connection table
face_full = B + repmat(face_mat, nele_L, 1);
%setup vert matrix
vert_mat = [0 0 0; d_FE_L 0 0; d_FE_L 0 -d_FE_L; 0 0 -d_FE_L;...
0 -d_FE_L 0;d_FE_L -d_FE_L 0; d_FE_L -d_FE_L -d_FE_L;0 -d_FE_L -d_FE_L];
x_mat = repmat(reshape(repmat((0:(nelx_L - 1))*d_FE_L, nelz_L*8, 1), [], 1), nely_L, 1);
y_mat = reshape(repmat((0:(nely_L-1))*d_FE_L*-1, (nelz_L*nelx_L*8), 1), [], 1);
z_mat = repmat(reshape(repmat(reshape(repmat((0:(nelz_L-1))*d_FE_L*-1, 8, 1), [], 1), 1, nelx_L), [], 1), nely_L, 1);
coords_mat = cat(2, x_mat, y_mat, z_mat);
vert_tot = coords_mat + repmat(vert_mat, nele_L, 1);
colour = repmat(reshape(repmat(reshape((1-xPhys), 1, []), 6,1), [], 1), 1, 3);
face_alpha = zeros(size(colour(:,1)));
face_alpha(colour(:,1)<=0.7) =1;
figure
view(-30, 30);
axis equal;
axis padded;
axis off;
patch('Faces',face_full,'Vertices',vert_tot, 'FaceVertexCData', colour, 'FaceVertexAlphaData', face_alpha,'FaceAlpha', 'flat', 'EdgeAlpha', 'flat', 'FaceColor','flat');
댓글 수: 2
Dyuman Joshi
2024년 1월 23일
"Previously i was able to use the FaceVertexAlphaData option to just plot the faces of the cubes with a density higher then 0.3."
Could you elaborate on this? Did you use a singular value as the value for the FaceVertexAlphaData argument, as opposed to using different values for each face that is done in the code above?
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!