📅 2010-Sep-14 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ distributions, geometry ⬩ 📚 Archive
A variety of point distributions are used in computer graphics and computational geometry to test out algorithms. Below are a few common point distributions and code to generate points in 3D. Assume that random()
is a random function that returns a floating point value in the range (0.0-1.0).
Uniform Distribution
Uniform distribution is the most common distribution used in practice. Generate point using random values of x, y and z.
x = random();
y = random(); z = random();
Sphere Distribution
do {
0.5;
x = random() - 0.5;
y = random() - 0.5;
z = random() -
d = ( x * x ) + ( y * y ) + ( z * z );
while ( ( d < ( 0.45 * 0.45 ) || ( d > ( 0.5 * 0.5) ) ) ); }
Half Sphere Distribution
do {
0.5;
x = random() - 0.5;
y = random() - 0.5;
z = random() -
d = ( x * x ) + ( y * y ) + ( z * z );
while ( ( z >= 0.2 ) || ( d < ( 0.45 * 0.45 ) ) || ( d > ( 0.5 * 0.5) ) ); }
Ball Distribution
do {
0.5;
x = random() - 0.5;
y = random() - 0.5;
z = random() -
d = ( x * x ) + ( y * y ) + ( z * z );
while ( d > ( 0.49 * 0.49 ) ); }
Empty Ball Distribution
do {
0.5;
x = random() - 0.5;
y = random() - 0.5;
z = random() -
d = ( x * x ) + ( y * y ) + ( z * z );
while ( d < ( 0.45 * 0.45 ) ); }
Ellipsoid Distribution
Ellipsoid has a surface but no volume inside.
0.5;
a = 0.5;
b = 0.2;
c =
do {
0.5;
x = random() - 0.5;
y = random() - 0.5;
z = random() -
d = ( ( x * x ) / ( a * a ) ) + ( ( y * y ) / ( b * b ) ) + ( ( z * z ) / ( c * c ) );
while ( ( d <= 1.4 ) || ( d >= 1.5 ) ); }
Pancake Distribution
0.5;
a = 0.5;
b = 0.2;
c =
do {
0.5;
x = random() - 0.5;
y = random() - 0.5;
z = random() -
d = ( ( x * x ) / ( a * a ) + ( y * y ) / ( b * b ) + ( z * z ) / ( c * c );
while ( d >= 1.0 ); }