expandByPoint method
point
- Vector3 that should be included in the
box.
Expands the boundaries of this box to include point
.
Implementation
BoundingSphere expandByPoint(Vector point ) {
if(isEmpty()){
center.setFrom( point );
radius = 0;
return this;
}
_v1.sub2(point, center);
final lengthSq = _v1.length2;
if ( lengthSq > ( radius * radius ) ) {
// calculate the minimal sphere
final length = math.sqrt( lengthSq );
final delta = ( length - radius ) * 0.5;
center.addScaled( _v1, delta / length );
radius += delta;
}
return this;
}