5
$\begingroup$

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..

$\endgroup$
2
  • 1
    $\begingroup$ You can probably project onto the xy, xz, or yz planes, pick a point, and then project back up. The jacobian of these maps will be constant, so my guess is that uniformly of choice is not destroyed. $\endgroup$
    – abnry
    Oct 24, 2013 at 18:30
  • $\begingroup$ Yeah, I thought of this also, but I was avoiding extra calculation. I mean, let's say that I project onto xy plane and pick points, when back projecting I need to calculate z value of all points using the first 3 points z value. And beside that I'm not sure if it is still be uniform, can you explain it little bit more detailed? What do you mean by jacobian will be constant? $\endgroup$
    – guneykayim
    Oct 24, 2013 at 18:38

2 Answers 2

3
$\begingroup$

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$.

$\endgroup$
3
  • $\begingroup$ I'll be back, after I try this :) $\endgroup$
    – guneykayim
    Oct 24, 2013 at 18:41
  • $\begingroup$ This will not work in some cases, such as when $a$ and $b$ are both $1$. In that case, $x$ will be $v_2 + v_3 - v_1$, which is probably not inside the triangle. $\endgroup$
    – Joel
    Sep 9, 2015 at 5:37
  • 5
    $\begingroup$ Important note: if $a + b >= 1$ then it will extend past the triangle. In such a case, set $a = 1 - a$ and $b = 1 - b$. $\endgroup$
    – Keavon
    Aug 3, 2017 at 22:58
1
$\begingroup$

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]$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .