I have to be able to set a random location for a waypoint for a flight sim. The maths challenge is straightforward:
\"To find a single random location within a quadrangl
Split your quadrangle into two triangles and then use this excellent SO answer to quickly find a random point in one of them.
Borrowing this great link from Akusete on picking a random point in a triangle.
(from MathWorld - A Wolfram Web Resource: wolfram.com)
Given a triangle with one vertex at the origin and the others at positions v1 and v2, pick
(from MathWorld - A Wolfram Web Resource: wolfram.com)
where A1 and A2 are uniform variates in the interval [0,1] , which gives points uniformly distributed in a quadrilateral (left figure). The points not in the triangle interior can then either be discarded, or transformed into the corresponding point inside the triangle (right figure).