Dear MATLAB Community,
I am currently stuck on defining an algorithm for generating a tubular shell geometry inside a tetrahedral volume.
My goal is to create a π/3 section of a circular tube cross-section that fits within a triangular region.
I have already implemented a simpler case where the pi/4 part of a circular tube axis is aligned with the edge from (0,0,0) to (0,0,1). In this configuration, the tube boundaries lie on one of the triangular faces of tetrahedron T6.
After defining the boundaries, I generate the mesh using the following code:
grid_size = 25;
R = 0.2;
theta = linspace(0, pi/4, grid_size);
t_span = linspace(0, 1, grid_size);
[Theta, T] = meshgrid(theta, t_span);
X_tube = R .* sin(Theta);
Y_tube = R .* cos(Theta);
Z_roof = 1;
Z_floor = Y_tube;
Z_tube = Z_floor + T .* (Z_roof - Z_floor);
mesh(X_tube, Y_tube, Z_tube, 'EdgeColor', 'b', 'FaceColor', 'none', 'LineWidth', 1.3);
However, I now want to orient the tube along the diagonal edge connecting (0,0,0) and (1,1,1) instead of the z-axis (vertical).
I have tried several approaches, but I have not been able to set the boundaries correctly.
The tetrahedral decomposition is generated as follows:
vertices = [0,0,0; 1,0,0; 1,1,0; 0,1,0;
0,0,1; 1,0,1; 1,1,1; 0,1,1];
t_indices = [
1, 2, 3, 7; % T1
1, 2, 6, 7; % T2
1, 4, 3, 7; % T3
1, 4, 8, 7; % T4
1, 5, 6, 7; % T5
1, 5, 8, 7 % T6 [Vertices: (0,0,0), (0,0,1), (0,1,1), (1,1,1)]
];
figure('Name', '6 Volumes with Flipped Tube Shell in T6', 'Color', 'w', 'Position', [100, 100, 900, 700]);
colors = lines(6);
hold on;
patch_handles = zeros(1, 6);
for i = 1:6
t = t_indices(i, :);
faces = [
t(1), t(2), t(3);
t(1), t(2), t(4);
t(1), t(3), t(4);
t(2), t(3), t(4)
];
current_alpha = 0.25;
if i == 6, current_alpha = 0.04; end
patch_handles(i) = patch('Vertices', vertices, 'Faces', faces, ...
'FaceColor', colors(i,:), ...
'FaceAlpha', current_alpha, ...
'EdgeColor', [0.2, 0.2, 0.2], ...
'LineWidth', 1);
centroid = mean(vertices(t, :), 1);
text(centroid(1), centroid(2), centroid(3), sprintf('T_%d', i), ...
'FontSize', 12, 'FontWeight', 'bold', 'Color', colors(i,:)*0.5, ...
'HorizontalAlignment', 'center');
end
The following figure is showing the geometry I would like to generate.
Any suggestions on how to formulate this in a general and reusable way would be greatly appreciated.

 채택된 답변

Mirhan
Mirhan 대략 5시간 전

0 개 추천

Dear community,
Thanks for your answers they were very helpful.
I needed to define the boundaries mathematically and i figured it out.
Thanks,
Best.

추가 답변 (2개)

Matt J
Matt J 대략 8시간 전
편집: Matt J 대략 8시간 전

0 개 추천

Obtain vertices for the complete, non-truncated cylinder Vcyl and the vertices Vtet for the tetrahedron containing it. Then, you can use intersectionHull from this File Exchange download,
to find the vertices of the intersection.
Vintersection = intersectionHull('vert', Vcyl, 'vert', Vtet).Vertices;
If you need the surface facets of the intersection, you can then just apply convhulln,
Facets = convhulln(Vintersection)
Matt J
Matt J 대략 7시간 전
편집: Matt J 대략 6시간 전

0 개 추천

Apply a 3x3 rotation matrix R to the tetrahderon which transforms the (0,0,0) to (1,1,1) edge so that it aligns with the z-axis. Then apply your original methodology for constructing the cylinder in that orientation. Then transform all of the vertices from both shapes back to their original desired positions.
The rotation matrix can be computed using this FEX doanload,

카테고리

제품

릴리스

R2024a

질문:

2026년 5월 29일 22:13

답변:

2026년 5월 30일 18:34

Community Treasure Hunt

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

Start Hunting!

Translated by