How can I evenly distribute Points inside of a triangle?
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Frederike Bodenstein
am 26 Sep. 2019
Beantwortet: Bruno Luong
am 26 Sep. 2019
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 Kommentare
Bruno Luong
am 26 Sep. 2019
Bearbeitet: Bruno Luong
am 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).
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!