I've been reading the following article... https://hbfs.wordpress.com/2010/10/05/random-points-in-a-triangle-generating-random-sequences-ii/
Which basically talks about how to generate a random point INSIDE of a triangle by:
- Making a copy of the triangle
- Transforming the copied triangle and joining the original triangle with the copied triangle to form a parallelogram.
- Generating a random point within the parallelogram.
- If the point is INSIDE of the COPIED triangle, map the point to the corresponding point in the ORIGINAL triangle.
I am currently on step 4 and I'm not understanding how exactly to transform the point into a point in the corresponding ORIGINAL triangle.
Could anyone help clarify how to accomplish this and what equation/formula is needed?
Suppose one point of the triangle is at the origin and the other two points have position vectors $\mathbf v_1$ and $\mathbf v_2$. Points are generated in the parallelogram as follows: $$\mathbf x=A\mathbf v_1+B\mathbf v_2$$ where $A$ and $B$ are independent and uniformly distributed on $[0,1]$.
$\mathbf x$ will lie in the original triangle if and only if $A+B\le1$. After generating the two random variables, if this test fails the random variables are transformed: $$A\to1-A,B\to1-B$$ This transformation maps the copied triangle to the original triangle. Having done this conditional transformation, calculating $\mathbf x$ is guaranteed to yield a point uniformly distributed over the desired triangle.