Triangular mesh between points

13 visualizzazioni (ultimi 30 giorni)
Ahmed
Ahmed il 22 Ago 2023
Risposto: Vinayak il 4 Gen 2024
I have the XYZ coordinates of a set of points if joined create the shape shown in the image, i was thinking of copying this array and changing the Z Value to generate the exact same shape at a different Z value. But i need help in generating a triangular mesh between these two shapes similar to the image attached

Risposte (1)

Vinayak
Vinayak il 4 Gen 2024
Hi Ahmed,
As you have not attached the images or data, the below code assumes you have a shape with 10 points in the form of a 10X3 matrix. I modifed the third column (z-index) while creating a new shape.
I have used delaunayTriangulation to generate the connections and plotted using a tetramesh.
% Sample Shape (Decagon)
theta = linspace(0, 2*pi, 10); % 10 points to create the star
radius1 = 1;
x1 = radius1 * cos(theta);
y1 = radius1 * sin(theta);
z1 = zeros(size(x1)); % Set a constant height for Shape 1
shape1 = [x1', y1', z1'];
% Slightly modify Z values for Shape 2
shape2 = shape1;
shape2(:, 3) = shape2(:, 3) + 5 * rand(size(shape1, 1), 1);
% Combine points
combinedPoints = [shape1; shape2];
triangulation = delaunayTriangulation(combinedPoints(:, 1), combinedPoints(:, 2), combinedPoints(:, 3));
% Plot the original shapes
figure;
scatter3(shape1(:, 1), shape1(:, 2), shape1(:, 3), 'r', 'filled');
hold on;
scatter3(shape2(:, 1), shape2(:, 2), shape2(:, 3), 'b', 'filled');
tetramesh(triangulation,'FaceAlpha',0.1);

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by