23 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

Sign in to answer this question.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/482216-how-can-i-evenly-distribute-points-inside-of-a-triangle#comment_750123

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/482216-how-can-i-evenly-distribute-points-inside-of-a-triangle#comment_750123

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/482216-how-can-i-evenly-distribute-points-inside-of-a-triangle#comment_750130

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/482216-how-can-i-evenly-distribute-points-inside-of-a-triangle#comment_750130

Sign in to comment.