def __init__(self, point1 = None, point2 = None, slab = None):
# Huaicai 4/23/05: added some comments below to help understand the code.
# convert from 2d (x, y) coordinates into its 3d world (x, y, 0)
#coordinates(the lower-left and upper-right corner).
#In another word, the 3d coordinates minus the z offset of the plane
x = dot(A(point1), A(point2))
# Get the vector from upper-right point to the lower-left point
dx = subtract.reduce(x)
# Get the upper-left and lower right corner points
oc = x + V(point2*dot(dx,point2),
# Get the four 3d cooridinates on the bottom crystal-cutting plane
sq1 = cat(x,oc) + slab.normal*dot(slab.point, slab.normal)
# transfer the above 4 3d coordinates in parallel to get that on
#the top plane, put them together
sq1 = cat(sq1, sq1+slab.thickness*slab.normal)
self.data = V(maximum.reduce(sq1), minimum.reduce(sq1))
# just 2 3d points
self.data = V(maximum(point1, point2), minimum(point1, point2))
# list of points: could be 2d or 3d? +/- 1.8 to make the bounding
#box enclose the vDw ball of an atom?
self.data = V(maximum.reduce(point1) + BBOX_MARGIN,
minimum.reduce(point1) - BBOX_MARGIN)
# a null bbox
self.data = None
Return the maximum distance from self's geometric center
to any point in self (i.e. the corner-center distance).
Note: This is the radius of self's bounding sphere,
which is as large as, and usually larger than, the
bounding sphere of self's contents.
Note: self's box dimensions are slightly larger than
needed to enclose its data, due to hardcoded constants
in its construction methods. [TODO: document, make optional]
if not self.data: return 10.0
dd = 0.5*subtract.reduce(self.data)
# dd = halfwidths in each dimension (x,y,z)
x = sqrt(dd*dd + dd*dd + dd*dd)
# x = half-diameter of bounding sphere of self
#return max(x, 2.0)
add.reduce(self.data) / 2,
subtract.reduce(self.data) / 2 )