How can I evenly distribute Points inside of a triangle?

14 views (last 30 days)
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 Comments
Bruno Luong
Bruno Luong on 26 Sep 2019
Edited: Bruno Luong on 26 Sep 2019
"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 on 26 Sep 2019
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

Sign in to comment.

Accepted Answer

Bruno Luong
Bruno Luong on 26 Sep 2019
Use mesh generator like MESH2D

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!