I'd like to sample points on a triangle randomly. The following code yields points that are uniformly distributed on a quadrilateral:
point = RandomReal[]*(v2-v1) + RandomReal[]*(v3-v1);
I'd like to take advantage of the symmetry and transform points chosen outside the triangle to their reflected position inside the triangle. It seems like this should be simple with ReflectionTransform, but so far, no dice. Here's some code to demonstrate:
Module[{vertices = {{0, 0, 0}, {1, 0, 0}, {0, 1, 1}}, p, r},
p = (RandomReal[] vertices[[2]] - vertices[[1]]) +
(RandomReal[] vertices[[3]] - vertices[[1]]);
r = ReflectionTransform[p];
Print["p=", p]; Print["r[p]=", r[p]];
Show[Graphics3D[{Red, Triangle[vertices]}],
Graphics3D[{Blue, PointSize[0.02], Point[vertices], Green,
PointSize[0.04], Point[p], Point[r[p]]}],
Graphics3D[Text[#, 1.05 #] &/@(vertices~Join~{p, r[p]})]]]
Obviously, the reflection above is not specified properly, but I would like to reflect the point, P, in the plane of the triangle to generate two corresponding points mirrored over the edge (v2 -> v3).





DirichletDistribution[]is built in, right? – J. M.'s missing motivation Aug 19 '15 at 03:09