Defining Triangular mesh with delaunay and inpolygon ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone;
I want to draw my shape functions in 3D over triangular domain:
S1=-1+2x+2y, shape functions contains x and y values.
I can triangulize the mesh (obtain 2 triangle)
[x,y] = meshgrid(0:1,0:1);
tri = delaunay(x,y);
trisurf(tri,x,y,zeros(size(x)))
But I want to only use points from one triangle.
I tried to use inpolygon but I dont understand how it works ?
0 comentarios
Respuestas (1)
John D'Errico
el 4 de Abr. de 2020
Editada: John D'Errico
el 4 de Abr. de 2020
Easy peasy. And there is no need to bother with inpolygon here.
[x,y] = meshgrid(0:.1:1);
xy = [x(:),y(:)];
xy(xy(:,1) > xy(:,2),:) = [];
tri = delaunayn(xy);
zfun = @(x,y) 1 + 2*x + 2*y;
z = zfun(xy(:,1),xy(:,2));
H = trisurf(tri,xy(:,1),xy(:,2),z);
H.EdgeColor = 'none';
H.FaceColor = 'interp';
xlabel X
ylabel Y
grid on
box on
Note that my use of a finer mesh allows you to have had a more complicated surface, with some curvature in there, even though the function you indicated was purely planar.
As necessary IF that shape function is nonlinear, make sure you know how to use the .* and .^ and ./ operators to allow for vectorized evaluation in the function.
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!