Surface plot of function over triangular domain

20 ビュー (過去 30 日間)
Gaudio
Gaudio 2015 年 8 月 21 日
コメント済み: Bruno Luong 2022 年 4 月 29 日
Hello,
I would like to create a surface plot over a triangular domain. The result should be a curved triangle. I have a little example here:
syms x y
z = x^2+y^2;
ezsurf(x,y,z);
hold on
% triangular domain with P(x,y)
P1 = [1,1];
P2 = [2,0.5];
P3 = [4,4];
plot([P1(1);P2(1);P3(1);P1(1)],[P1(2);P2(2);P3(2);P1(2)]);
All z values for x,y combinations inside the triangle shall be plotted. The rims should not look like steps. Do you have any suggestions?
Thanks a lot.
Ps: I am using Symbolic Math Toolbox (as you might see)
  2 件のコメント
Gaudio
Gaudio 2015 年 8 月 26 日
Hello everybody,
I was able to solve my Problem with DelaunayTriangulation and inpolygon.
Best, Gauido
Noah Stam
Noah Stam 2022 年 4 月 29 日
Can you elaborate on your solution? :P

サインインしてコメントする。

回答 (1 件)

Bruno Luong
Bruno Luong 2022 年 4 月 29 日
編集済み: Bruno Luong 2022 年 4 月 29 日
P1 = [1,1];
P2 = [2,0.5];
P3 = [4,4];
zfun = @(x,y) x.^2+y.^2;
% Create triangular mesh of triangla P1,P2,P3
n=20;
[I,J]=meshgrid(linspace(0,1,n));
keep=I+J <= 1+eps;
IJ = [I(keep),J(keep)];
K = 1-sum(IJ,2);
F=delaunay(IJ);
IJK = [IJ,K];
XY=IJK*[P1;P2;P3];
x=XY(:,1);
y=XY(:,2);
trisurf(F,x,y,zfun(x,y))
  2 件のコメント
Noah Stam
Noah Stam 2022 年 4 月 29 日
Thanks a lot!
Bruno Luong
Bruno Luong 2022 年 4 月 29 日
You are welcome. Please accept the answer if it helps. Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by