How to sample points on a triangle surface in 3D?

4.8k Views Asked by At

To take random uniform points inside a triangle Triangle Point Picking method is used. But this is for 2D points, how can I take random points from a triangle that is defined by 3 arbitrary 3D points?

In other words, let's say I have 3 points in 3D space, and these points define a plane, how can I take random points on the plane such that my points are uniformly sampled inside the triangle that is defined by these 3 points?

Thanks in advance..

2

There are 2 best solutions below

3
On BEST ANSWER

The same exact algorithm should work in $3D$ too: $$\vec{x} = \vec{v_1} + a (\vec{v_2} -\vec{v_1}) + b (\vec{v_3} -\vec{v_1})$$ Where $a,b$ are uniformly distributed in $[0,1]$ and the $\vec{v}$'s are the triangle vertices in $3D$.

0
On

As mentioned in the comments, this formulation is not guaranteed to give you points on the triangle. The correct formulation is as follow:

$P = (1 - \sqrt{a})v1 + (\sqrt{a} (1 - b))v2 + (b \sqrt{a})v3$

where $a, b \sim U[0, 1]$.