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

12 vues (au cours des 30 derniers jours)
Tom Engels
Tom Engels le 6 Août 2021
Commenté : Tom Engels le 16 Août 2021
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
Tom
  2 commentaires
darova
darova le 8 Août 2021
Please attach an extreme case
Tom Engels
Tom Engels le 9 Août 2021
Modifié(e) : Tom Engels le 9 Août 2021
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.

Connectez-vous pour commenter.

Réponse acceptée

darova
darova le 14 Août 2021
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 commentaire
Tom Engels
Tom Engels le 16 Août 2021
Hello darova,
thank you very much for your good support. With this idea, I can definitely serve all flat surfaces without interruptions.
Regards
Tom

Connectez-vous pour commenter.

Plus de réponses (2)

darova
darova le 9 Août 2021
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')
light
axis equal
view(45,45)
Work with cartesian/spherical system of coordinates to manipulate elements of a spherical objects
  7 commentaires
darova
darova le 12 Août 2021
I can't build a mesh with your data. Can you show how?
s1 = load('points.mat')
s1 = struct with fields:
point_and_normal2: [112×3 double]
% p = s1.point_and_normal2;
s2 = load('coordVERTICIES.mat')
s2 = struct with fields:
coordVERTICES: [110×3×3 double]
t = s2.coordVERTICES;
plot(squeeze(t(:,1,:))',squeeze(t(:,2,:))','k')
darova
darova le 12 Août 2021
Modifié(e) : darova le 12 Août 2021
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);
end
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
view(0,90)
axis equal

Connectez-vous pour commenter.


Tom Engels
Tom Engels le 13 Août 2021
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,:) )';
patch(xco,yco,zco,'k','EdgeColor','k','FaceColor','#a8afb3');
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

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by