public String toString() { return "{"+getCenter()+":"+getRadius()+"}"; }
/** * Expands this box to include the specified bounding sphere. * @param bs the bounding sphere. */ public void expandBy(BoundingSphere bs) { if (!bs.isInfinite()) { if (!bs.isEmpty()) { double r = bs.getRadius(); Point3 c = bs.getCenter(); double x = c.x; double y = c.y; double z = c.z; if (_xmin>x-r) _xmin = x-r; if (_ymin>y-r) _ymin = y-r; if (_zmin>z-r) _zmin = z-r; if (_xmax<x+r) _xmax = x+r; if (_ymax<y+r) _ymax = y+r; if (_zmax<z+r) _zmax = z+r; } } else { setInfinite(); } }
/** * Determines whether the view frustrum intersects the bounding sphere * of the specified node. * @param node the node with a bounding sphere. * @return true, if the view frustum intersects the bounding sphere; * false, otherwise. */ public boolean frustumIntersectsSphereOf(Node node) { if (_active!=0) { // if at least one frustum plane is active, ... BoundingSphere bs = node.getBoundingSphere(false); if (bs.isEmpty()) return false; if (bs.isInfinite()) return true; Point3 c = bs.getCenter(); double r = bs.getRadius(); double s = -r; for (int i=0,plane=1; i<6; ++i,plane<<=1) { // for all six planes if ((_active&plane)!=0) { // if plane is active double d = _planes[i].distanceTo(c); // distance from center if (d<s) { // if sphere is entirely outside (below plane) return false; // no intersection } else if (d>r) { // else if sphere is entirely above plane _active ^= plane; // need not test this plane again } } } } return true; }
Point3 b = _nearPoint; Point3 c = bs.getCenter(); double r = bs.getRadius(); double rr = r*r; double ax = a.x;
/** * Computes the transform matrix for this handle in the specified context. * The context is view-dependent, as is the computed transform matrix. * This matrix includes the view-dependent scaling required for the * handle to have the correct size in pixels. * @param tc the transform context. * @return the transform matrix for this handle. */ private Matrix44 computeTransform(TransformContext tc) { View view = tc.getView(); Tuple3 as = view.getAxesScale(); Matrix44 localToPixel = tc.getLocalToPixel().times(_transform); Matrix44 pixelToLocal = localToPixel.inverse(); Point3 p = new Point3(0.0,0.0,0.0); Point3 q = localToPixel.times(p); q.x += getSize(); q = pixelToLocal.times(q); double dx = (q.x-p.x)*as.x; double dy = (q.y-p.y)*as.y; double dz = (q.z-p.z)*as.z; double d = Math.sqrt(dx*dx+dy*dy+dz*dz); double r = _boundingSphereChildren.getRadius(); double s = d/r; double sx = s/as.x; double sy = s/as.y; double sz = s/as.z; return _transform.times(Matrix44.scale(sx,sy,sz)); } }
double ty = -c.y; double tz = -c.z; double r = (!ws.isEmpty())?ws.getRadius():1.0; double s = (r>0.0)?1.0/r:1.0; double sx = s*as.x;
BoundingSphere bs = super.computeBoundingSphere(finite); if (!bs.isEmpty() && !bs.isInfinite()) { double r = bs.getRadius(); Point3 c = bs.getCenter(); Point3 x = new Point3(c.x+r,c.y,c.z);