Defining Triangular mesh with delaunay and inpolygon ?

조회 수: 1 (최근 30일)
eda yilmas
eda yilmas 2020년 4월 4일
댓글: eda yilmas 2020년 4월 4일
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 ?

답변 (1개)

John D'Errico
John D'Errico 2020년 4월 4일
편집: John D'Errico 2020년 4월 4일
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
eda yilmas
eda yilmas 2020년 4월 4일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by