Notifications
Clear all

[Closed] Uniform distribution

Hi,
I’m wondering how to get the uniform distribution of random points inside a triangle. I came up with an idea of using barycentric coordinates with randomly generated t1, t2, t3 coords which sum to 1.0, but I can’t get this uniform distribution at all.

My first thought was:

delete objects
p1 = [50,0,0]
p2 = [-50,0,0]
p3 = [0,100,0]
for i = 1 to 1000 do
(
	--generating random values
	t1 = random 0.0 1.0
	t2 = random 0.0 (1.0-t1)
	t3 = 1.0 - t1 - t2
	
	p = p1 * t1 + p2 * t2 + p3 * t3
	geosphere radius:0.5 pos:p segs:2 wirecolor:yellow
)

It sucks, because majority of my points is near the p1, because t1 value is almost always the biggest one, so I came up with another idea:

delete objects
p1 = [50,0,0]
p2 = [-50,0,0]
p3 = [0,100,0]
for i = 1 to 1000 do
(
	--generating random values
	t1 = random 0.0 1.0
	t2 = random 0.0 1.0
	t3 = random 0.0 1.0
	sum = t1 + t2 + t3
	t1 /= sum
	t2 /= sum
	t3 /= sum
	
	p = p1 * t1 + p2 * t2 + p3 * t3
	geosphere radius:0.5 pos:p segs:2 wirecolor:yellow
)

It also sucks, majority of my poits are near the center of my triangle… Any tips?

1 Reply

this might have something useful, from another thread, can’t remember how uniform it was