How to place/ define points on a triangulated meshed surface?

조회 수: 19(최근 30일)
Hello all,
I need your help and ideas to solve the following problem.
I have a surface that is meshed with triangles. I know the positions of the nodes, as well as the normal vector of the node and the surfaces (as a unit vector).
For example, the surface looks like this:
However, the surface can also be round, have holes in it or have a completely free external shape. In extreme cases, the surface is even curved in space (e.g. like a spherical surface).
I would now like to place as many cylinders as I want on this surface, which always have the maximum distance from each other.
Does anyone know how this can be done?
Or how can I find and define points on this "surface"?
Many thanks and greetings
  댓글 수: 2
Tom Engels
Tom Engels 2021년 8월 9일
편집: Tom Engels 2021년 8월 9일
The following cases represent an example of an extreme case:
For one cylinder, I determine the centroid of the surface and use the local curvature to check whether I could place it there.

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

채택된 답변

darova 2021년 8월 14일
Here is another approach, but works only if you don't have points inside:
  • pick a point inside a contour (center)
  • convert data into polar coordinates
  • sort by angle
coord = load('coordVERTICIES.mat');
coordVERTICES = coord.coordVERTICES;
xco = coordVERTICES(:,1,:);
yco = coordVERTICES(:,2,:);
zco = coordVERTICES(:,3,:);
[x,y,z] = deal(xco(:),yco(:),zco(:));
[t,r] = cart2pol(x-mean(x),y-mean(y)); % convert to polar system
[~,k] = sort(t); % sort angle
x1 = x(k);
y1 = y(k);
dl = hypot(diff(x1),diff(y1)); % find distance between points
k1 = find(dl > 0.01); % remove zero distances (duplicate points)
gd = [2;numel(k1);x1(k1);y1(k1)]; % geom descr
dl = decsg(gd); % decomposition
[p,e,t] = initmesh(dl); % build a new mesh
plot(x,y,'.g') % plot all points
hold on
plot(x(k),y(k)) % plot boundary curve
pdemesh(p,e,t) % plot mesh
plot(mean(x),mean(y),'ob','markersize',15,'linewidth',3) % center of a figure
hold off
axis equal tight
  댓글 수: 1
Tom Engels
Tom Engels 2021년 8월 16일
Hello darova,
thank you very much for your good support. With this idea, I can definitely serve all flat surfaces without interruptions.

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

추가 답변(2개)

darova 2021년 8월 9일
How about simple griddata with using initmesh
t = 0:.2:5;
x = [t; t]; % some data
y = [t*0; t*0+3]; % some data
z = [sin(t); sin(1.2*t)]; % some data
k = boundary(x(:),y(:)); % simply find only boundary
x1 = x(k(2:end)); % boundary should be unclosed curve
y1 = y(k(2:end)); % boundary should be unclosed curve
gd = [2;numel(x1);x1(:);y1(:)]; % geometry description
dl = decsg(gd); % decomposition
[p,e,t] = initmesh(dl,'Hmax',0.1);% build a mesh (control mesh size)
z2 = griddata(x(:),y(:),z(:),p(1,:),p(2,:)); % find Z coordinate for each point
pp.vertices = [p' z2(:)]; % create struct for patch
pp.faces = t(1:3,:)'; % create struct for patch
pp.facecolor= 'r'; % create struct for patch
h1 = plot3(x,y,z,'.-g');
h2 = patch(pp);
legend([h1(1) h2],'original data','gridata/initmesh')
axis equal
Work with cartesian/spherical system of coordinates to manipulate elements of a spherical objects
  댓글 수: 7
darova 2021년 8월 12일
편집: darova 2021년 8월 12일
Here is another example with using feeBoundary. It find free edges. The problem with separating outer and inner edges remains.
% generating the data
t = linspace(0,2*pi,50);
[x1,y1] = pol2cart(t,1); % inner curvw
x2 = 2*x1 + 0.2*cos(5*t); % outer curve
y2 = 2*y1 + 0.2*sin(5*t);; % outer curve
x = zeros(numel(x1),10); % preallocation
y = x;
for i = 1:numel(x1)
x(i,:) = linspace(x1(i),x2(i),10); % create nodes between curves
y(i,:) = linspace(y1(i),y2(i),10);
h = surf(x,y,x*0); % create surface object
p = surf2patch(h,'triangles'); % conver surface object to patch
TR = triangulation(p.faces,p.vertices); % trinagulation
v = p.vertices;
E = freeBoundary(TR); % find boundary edges
p.vertices(:,1) = p.vertices(:,1) + 5; % move patch object
patch(p,'facecolor','r') % display triangles
line(v(E,1)+5,v(E,2),'color','g','linewidth',2) % ree boundary
axis equal

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

Tom Engels
Tom Engels 2021년 8월 13일
Hello davora. Thank you for your answer and help. I am currently creating the network from the data in the .stl file as follows:
coord = load('coordVERTICIES.mat')
coordVERTICES = coord.coordVERTICES;
xco = squeeze( coordVERTICES(:,1,:) )';
yco = squeeze( coordVERTICES(:,2,:) )';
zco = squeeze( coordVERTICES(:,3,:) )';
axis equal tight
Unfortunately, if I understand the freeboundary command correctly, it is limited to meshing a two-dimensional surface. The consideration of curvatures would therefore unfortunately not be possible.
Do you have any idea how I could create points on the surface efficiently in a different way?
Greetings Tom


Find more on Triangulation Representation in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by