MATLAB Answers

How can I evenly distribute Points inside of a triangle?

6 ビュー (過去 30 日間)
Frederike Bodenstein
Frederike Bodenstein 2019 年 9 月 26 日
回答済み: Bruno Luong 2019 年 9 月 26 日
Hello,
I am trying to solve this problem: I need to distribute points evenly inside a triangle. The outlines also should be met by the points. The sides of the triangle are defined by parts of linear equations.
I first tried to get the intersectionpoints of a family of functions of these three equations, as can be seen in the code below. Since the points are not really evenly distributed, I tried to increase the number of functions belonging to y1 by 3, but this doesnt solve the issue.
I found the trimesh option, which I think could be useful if used only inside of the triangle instead of the complete surface, but I could not figure out how to apply trimesh only to the triangle. Is there a method to do this?
Or is there a better option to distribute points inside of the triangle?
Thank you for your answers in advance!
%Zeichnen der Außenlinien des dreiecks in den relevanten x-Bereichen
clear
clear all
n = 10;
m = 15;
c = linspace(0,1,m);
d = linspace(0,1/3,m);
e = linspace(0,1/4,m);
for i = 1:length(c)
x11 = 1/2*c(i) + 1/2;
x12 = 2/3*c(i) + 1/3;
x1 = linspace(x11,x12,n);
y1 = x1 - c(i);
f1(i,:) = y1;
plot(x1, y1);
hold on;
end
for i = 1:length(d)
x21 = 1/2 - 1/2*d(i);
x22 = 1 - 2*d(i);
x2 = linspace(x21,x22,n);
y2 = -x2 + 1 - d(i);
f2(i,:) = y2;
plot(x2, y2);
hold on;
end
for i = 1:length(e)
x31 = 1/3 + 2/3*e(i);
x32 = 1 - 2*e(i);
x3 = linspace(x31,x32,n);
y3 = -1/2*x3 + 1/2 + e(i);
f3(i,:) = y3;
plot(x3, y3);
hold on
end

  2 件のコメント

Bruno Luong
Bruno Luong 2019 年 9 月 26 日
"I first tried to get the intersectionpoints of a family of functions of these three equations, as can be seen in the code below. Since the points are not really evenly distributed,"
It's not clear what you are after.
Well you have to define what for you is "evently distributed".
To me your code produces points that are pretty much well distributed in the sense that the density of the points are identical at all place inside the triangles.
Granted the distance of the closest point depend on the direcion we look but this is not spatial characteristic but direction (isotropic/anisotropic).
Frederike Bodenstein
Frederike Bodenstein 2019 年 9 月 26 日
Thank you for your answer!
What I am trying to achieve is isotropic behavior of the points then. At the moment the distance between points in y1 direction is smaller than in the direction of y2 or y3. I would like it to be independent of direction.Point_distribution.JPG

サインイン to comment.

採用された回答

Bruno Luong
Bruno Luong 2019 年 9 月 26 日
Use mesh generator like MESH2D

  0 件のコメント

サインイン to comment.

その他の回答 (0 件)

サインイン してこの質問に回答します。


Translated by