Defining Triangular mesh with delaunay and inpolygon ?

1 visualización (últimos 30 días)
eda yilmas
eda yilmas el 4 de Abr. de 2020
Comentada: eda yilmas el 4 de Abr. de 2020
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 ?

Respuestas (1)

John D'Errico
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.
  1 comentario
eda yilmas
eda yilmas el 4 de Abr. de 2020
Thank you so much :)
I try to understand what u did in your code step by step, I only change the following step
xy(xy(:,1) > xy(:,2),:) = [];
to define another triangular mesh :)
Have a good day

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by