필터 지우기
필터 지우기

Triangular mesh between points

조회 수: 1 (최근 30일)
Ahmed
Ahmed 2023년 8월 22일
답변: Vinayak 2024년 1월 4일
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
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2023년 8월 22일
There is no image attached.

댓글을 달려면 로그인하십시오.

답변 (1개)

Vinayak
Vinayak 2024년 1월 4일
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);

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by