Random Point In Triangle
From CGAFaq
One way to choose a random point in a triangle is based on Barycentric_Coordinates.
Let A, B, C be the three vertices of your triangle. Any point P inside can be expressed uniquely as P = aA + bB + cC, where a+b+c=1 and a,b,c are each ≥ 0. Knowing a and b permits you to calculate c=1-a-b. So if you can generate two random numbers a and b, each in [0,1], such that their sum ≤ 1, you’ve got a random point in your triangle.
One way to do this is to generate random a and b independently and uniformly in [0,1] (just divide the standard C rand() by its max value to get such a random number.) If a+b>1, replace a by 1-a, b by 1-b. Let c=1-a-b. Then aA + bB + cC is uniformly distributed in triangle ABC: the reflection step a=1-a; b=1-b gives a point (a,b) uniformly distributed in the triangle (0,0)(1,0)(0,1), which is then mapped affinely to ABC. Now you have barycentric coordinates a,b,c. Compute your point P = aA + bB + cC.
Reference:
- [Gems I], Turk, pp. 24-28, contains a different method that requires a square root but that preserves stratification across the triangle better if stratified random numbers are used.

