How to place/ define points on a triangulated meshed surface?
12 visualizzazioni (ultimi 30 giorni)
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
Risposta accettata
darova
il 14 Ago 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
Più risposte (2)
darova
il 9 Ago 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 Commenti
darova
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')
darova
il 12 Ago 2021
Modificato: darova
il 12 Ago 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
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!