Space coordinates of points in mesh

3 次查看(过去 30 天)
i have developed a mesh-model of a 3D tank in PDE Toolbox. For specifying the boundary conditions, I need the space coordinates of the points along the free surface/upper boundary. When using the command meshToPet in the PDE Toolbox, I am able to get the space coordinates of the points in the mesh. If I have 205 points along the upper boundary, do the first 205 rows of the p matrix correspond to these points along the upper boundary? Does the following command call the points along the upper boundary?
x=p(1,1:205);
If not, how do i call the elements along a boundary/edge? In what order are the points specified in the p matrix?

回答(1 个)

Mann Baidi
Mann Baidi 2024-4-2
编辑:Mann Baidi 2024-4-2
Hi Shreya,
As per my understanding of the above question, you would like to find the space coordinates for the upper surface of your 3D model. Assuming you currently have the mesh matrix as ‘p’.
For finding the coordinates of the upper surface in the ‘p’ matrix, you will need to find the indices where the z-coordinates has the maximum value. Then we can extract the space coordinates of the maximum z-coordinates using the ‘find’ function in MATLAB. You can refer to the below code for extracrting the coordinates.
Find the maximum z-coordinate value
max_z = max(p(3,:));
% Find indices of points with maximum z-coordinate
upper_boundary_indices = find(p(3,:) == max_z)
% Extract upper boundary points
upper_boundary_points = p(:,upper_boundary_indices);
Here is an illustration code which highlights the upper surface of a 3D model.
model = femodel(Geometry="BracketTwoHoles.stl");
model= generateMesh(model);
mesh=model.Geometry.Mesh;
pdeplot3D(mesh);
hold on
[p,y,z]= meshToPet(mesh);
% Find the maximum z-coordinate value
max_z = max(p(3,:));
% Find indices of points with maximum z-coordinate
upper_boundary_indices = find(p(3,:) == max_z);
% Extract upper boundary points
upper_boundary_points = p(:,upper_boundary_indices)
upper_boundary_points = 3x209
0 0 20.0000 20.0000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 20.0000 20.0000 20.0000 20.0000 20.0000 20.0000 20.0000 200.0000 0 200.0000 0 10.0000 20.0000 30.0000 40.0000 50.0000 60.0000 70.0000 80.0000 90.0000 100.0000 110.0000 120.0000 130.0000 140.0000 150.0000 160.0000 170.0000 180.0000 190.0000 10.0000 20.0000 30.0000 40.0000 50.0000 60.0000 70.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000 100.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
% Plotting the upper surface points with red color
scatter3(upper_boundary_points(1,:), upper_boundary_points(2, :), upper_boundary_points(3, :), 'MarkerEdgeColor', [1 0 0]);
hold off;
Feel free to explore more functionalities of 'find' function by using the documentation link below:
I hope this helps in resolving the query.

类别

Help CenterFile Exchange 中查找有关 Geometry and Mesh 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by