필터 지우기
필터 지우기

How do you convert a surf object to an isosurface?

조회 수: 8 (최근 30일)
Kurt
Kurt 2024년 5월 6일
댓글: Kurt 2024년 5월 16일
How to convert a regular surf surface (rectangular mesh) to a patch isosurface (triangular mesh)?
I have seen how to go the other direction, but this one eludes me. After creating the isosurface, I need to run inpolyhedron() to see if points are inside or outside the object.
theta = (pi:0.1:pi);
phi = 0:0.1:pi);
[THETA, PHI] = meshgrid(theta, phi);
x = cos(THETA).* sin(PHI);
y = sin(THETA).*sin(PHI);
z = cos(PHI;
ellipsoid = surf(x,y,z);
(Extract the isosurface from the ellipsoid...)
fv = isosurface(something something ...)
pts = rand(5,3);
in = inpolyhedron(fv,pts); % check if points are inside or outside object
  댓글 수: 2
John D'Errico
John D'Errico 2024년 5월 6일
It is an ellipsoid though! It is far simpler to test if a point lies inside an ellipsoid, if that is all you need.
Kurt
Kurt 2024년 5월 6일
It's actually more complex than that. I bend and shape the ellipsoid to resemble a radar beam.

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

채택된 답변

Yatharth
Yatharth 2024년 5월 14일
Hi Kurt,
You can use the "delaunayTriangulation" function, to convert the rectangular mesh to a triangular mesh.
for your given code, here is how you can use the function:
theta = (0:0.1:2*pi); % Corrected range for theta
phi = (0:0.1:pi);
[THETA, PHI] = meshgrid(theta, phi);
x = cos(THETA).* sin(PHI);
y = sin(THETA).*sin(PHI);
z = cos(PHI);
h = surf(x,y,z);
axis equal; % Equal aspect ratio for all axes
X = get(h, 'XData');
Y = get(h, 'YData');
Z = get(h, 'ZData');
% Flatten the matrices
x = X(:);
y = Y(:);
z = Z(:);
figure;
DT = delaunayTriangulation(x, y, z);
Warning: Duplicate data points have been detected and removed.
The Triangulation indices are defined with respect to the unique set of points in delaunayTriangulation.
tetramesh(DT, 'FaceAlpha', 0.3); % Adjust 'FaceAlpha' for transparency
axis equal;
You can refer to the "delaunaytriangulation" function documentation here https://www.mathworks.com/help/matlab/ref/delaunaytriangulation.html
  댓글 수: 3
Yatharth
Yatharth 2024년 5월 15일
Hello, have you tried using "pointLocation" function? https://www.mathworks.com/help/matlab/ref/delaunaytri.pointlocation.html
for making it invisible set the "FaceAlpha" to 0.
Kurt
Kurt 2024년 5월 16일
I think if I do my ECEF coordinate conversion first and then extract the tetramesh, it just might work.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by