Generation of random coplanar points in three-dimensional space

I need to create random coplanar points in three-dimensional space. The flat equation:

a*x + b*y + c*z = d

I generate a plane by randomizing a, b, c and d. To create random points on this plane, I use this code:

    switch(random.nextInt(3))
    {
        case 0:
        {
            x = random.nextInt(length);
            y = random.nextInt(width);
            z = (d - (a*x) - (b*y))/c;
            break;
        }
        case 1:
        {
            x = random.nextInt(length);
            z = random.nextInt(height);
            y = (d - (a*x) - (c*z))/b;
            break;
        }
        case 2:
        {
            y = random.nextInt(width);
            z = random.nextInt(height);
            x = (d - (b*y) - (c*z))/a;
            break;
        }
    }

But when I use the Cayley-Menger determinant to check if the points are coplanar, the determinant is never zero (i.e. the points are not in the same plane).

An interesting point is that when creating points on the x = 0 plane, the Cayley-Menger determinant works fine!

Is it a rounding error or something else?

EDIT: length, width and height are integer values.

+3
source share

All Articles