You have a 3x3x3 cube. You bore a circular hole, of diameter 1, from the center of the top face to the center of the bottom face. You bore a similar hole from the left face center to the right face center, and another hole from front center to back center. How much material was removed?
The volume of material removed from all but the central 1x1 cubelet is 6*pi*(1/4)^2, or about 4.712.
The following program chooses points at random in the central cubelet and finds what fraction are within any of the three cylinders:
x = RND(1) - .5#: x2 = x * x
y = RND(1) - .5#: y2 = y * y
z = RND(1) - .5#: z2 = z * z
IF x2 + y2 < .25# OR x2 + z2 < .25# OR y2 + z2 < .25# THEN
hit = hit + 1
tries = tries + 1
IF tries MOD 1000 = 0 THEN PRINT hit, tries, hit / tries
It finds about .942 as the volume of the portion of the central cubelet that is removed. Together with the purely cylindrical portions that comes to 5.654.
Posted by Charlie
on 2005-03-06 17:42:42