Filter löschen
Filter löschen

Gyroid Surface Area & Volume Calculation from existing code

54 Ansichten (letzte 30 Tage)
The following code is to generate the shape of gyroid. From the code I want to calculate the surface area and volume. Instead of exporting the file and imprt in 3D design software could a potential solution, I want to get the surface area and volume from the code below:
clc
clear
close all
SizeL = 20;
Def = 40;
SFact = (SizeL/2)/pi;
A = SFact*pi;
D = A/Def;
[X,Y,Z] = meshgrid(-A:D:A);
OBJ = cos(X/SFact).*sin(Y/SFact) + cos(Y/SFact).*sin(Z/SFact) + cos(Z/SFact).*sin(X/SFact);
T = 0.5;
OBJ = (OBJ - T) .* (OBJ + T);
[F1,V1] = isosurface(X,Y,Z,OBJ,0);
[F2,V2] = isocaps(X,Y,Z,OBJ,0,'below');
F3 = [F1; F2+length(V1(:,1))];
V3 = [V1;V2];
p = patch('Vertices',V3,'Faces', F3, 'FaceColor', 'red', 'EdgeColor', 'none');
view(3);
camlight
Code Source: https://www.youtube.com/watch?v=uvCfVsFAcSw

Akzeptierte Antwort

Abhinaya Kennedy
Abhinaya Kennedy am 28 Nov. 2023
Hi Syed,
As I understand, you would like to calculate the surface area and volume of a gyroid by adding to the code you have provided. Here is one possible way of obtaining it.
% Surface Area Calculation
SA = 0;
for i = 1:size(F3, 1)
v1 = V3(F3(i, 1), :);
v2 = V3(F3(i, 2), :);
v3 = V3(F3(i, 3), :);
edge1 = v2 - v1;
edge2 = v3 - v1;
area = 0.5 * norm(cross(edge1, edge2));
SA = SA + area;
end
% Volume Calculation
Volume = 0;
centroid = mean(V3, 1);
for i = 1:size(F3, 1)
v1 = V3(F3(i, 1), :);
v2 = V3(F3(i, 2), :);
v3 = V3(F3(i, 3), :);
Volume = Volume + abs(dot(v1 - centroid, cross(v2 - centroid, v3 - centroid))) / 6;
end
% Displaying the results
disp(['Surface Area: ', num2str(SA)]);
disp(['Volume: ', num2str(Volume)]);
This will output the required information.
Hope this helps!
  1 Kommentar
jixiong fei
jixiong fei am 31 Mär. 2024
can you please tell me what the following mean?
abs(dot(v1 - centroid, cross(v2 - centroid, v3 - centroid))) / 6;

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by