How to place/ define points on a triangulated meshed surface?
Mostra commenti meno recenti
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 Commenti
darova
il 8 Ago 2021
Please attach an extreme case
Tom Engels
il 9 Ago 2021
Modificato: Tom Engels
il 9 Ago 2021
Risposta accettata
Più risposte (2)
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 Commenti
Tom Engels
il 10 Ago 2021
Tom Engels
il 10 Ago 2021
darova
il 11 Ago 2021
DO you have coordinates of edges (separately for outer and inner)?
Try to change shrink factor in boundary function
x = rand(30,1);
y = rand(30,1);
k1 = boundary(x,y,0.9);
k2 = boundary(x,y,0.2);
plot(x,y,'.g')
line(x(k1),y(k1),'color','r')
line(x(k2),y(k2),'color','b')
Tom Engels
il 12 Ago 2021
I can't build a mesh with your data. Can you show how?
s1 = load('points.mat')
% p = s1.point_and_normal2;
s2 = load('coordVERTICIES.mat')
t = s2.coordVERTICES;
plot(squeeze(t(:,1,:))',squeeze(t(:,2,:))','k')
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
Tom Engels
il 13 Ago 2021
Categorie
Scopri di più su Surface and Mesh Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!














