/** * Sets the radius of this bounding sphere from a double. * @param r the new radius for the bounding sphere */ public void setRadius(double r) { radius = r; updateBoundsStates(); }
/** * Combines this bounding sphere with a point. * @param point a 3D point in space */ @Override public void combine(Point3d point) { double dis,oldc_to_new_c; if( boundsIsInfinite) { return; } if( boundsIsEmpty) { radius = 0.0; center.x = point.x; center.y = point.y; center.z = point.z; } else { dis = Math.sqrt( (point.x - center.x)*(point.x - center.x) + (point.y - center.y)*(point.y - center.y) + (point.z - center.z)*(point.z - center.z) ); if( dis > radius) { radius = (dis + radius)*.5; oldc_to_new_c = dis - radius; center.x = (radius*center.x + oldc_to_new_c*point.x)/dis; center.y = (radius*center.y + oldc_to_new_c*point.y)/dis; center.z = (radius*center.z + oldc_to_new_c*point.z)/dis; } } updateBoundsStates(); }
/** * Constructs and initializes a BoundingSphere from a center and radius. * @param center the center of the bounding sphere * @param radius the radius of the bounding sphere */ public BoundingSphere(Point3d center, double radius) { boundId = BOUNDING_SPHERE; this.center = new Point3d(center); this.radius = radius; updateBoundsStates(); }
/** * Sets the position of this bounding sphere from a point. * @param center a Point defining the new center of the bounding sphere */ public void setCenter(Point3d center) { this.center.set(center); updateBoundsStates(); }
throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere2")); updateBoundsStates();
throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere3")); updateBoundsStates();
newBoundSphere.radius = radius; status = true; newBoundSphere.updateBoundsStates(); newBoundSphere.radius = sphere.radius; status = true; newBoundSphere.updateBoundsStates();
newBoundSphere.updateBoundsStates(); return true;