union method
sphere
- Bounding sphere that will be unioned with this
sphere.
Expands this sphere to enclose both the original sphere and the given sphere.
Implementation
BoundingSphere union(BoundingSphere sphere ) {
if (sphere.isEmpty()) {
return this;
}
if (isEmpty()){
setFrom(sphere);
return this;
}
if(center.equals(sphere.center) == true ) {
radius = math.max(radius, sphere.radius );
} else {
_v2.sub2(sphere.center, center).setLength(sphere.radius);
expandByPoint(_v1.setFrom( sphere.center ).add(_v2));
expandByPoint(_v1.setFrom( sphere.center ).sub( _v2));
}
return this;
}