Triangular mesh between points
조회 수: 13 (최근 30일)
이전 댓글 표시
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개)
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.
% 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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!