14#ifndef OSG_BOUNDINGSPHERE
15#define OSG_BOUNDINGSPHERE 1
101 template<
typename vector_type>
102 void expandBy(
const vector_type& v);
107 template<
typename vector_type>
122 template<
typename BBT>
127 template<
typename BBT>
141 return valid() &&
bs.valid() &&
148template<
typename vector_type>
158 _center += dv*(dr/r);
170template<
typename vector_type>
176 if (r>_radius) _radius = r;
190 if (!sh.
valid())
return;
203 double d = ( _center - sh.
center() ).length();
206 if ( d + sh.
radius() <= _radius )
212 if ( d + _radius <= sh.
radius() )
226 double new_radius = (_radius + d + sh.
radius() ) * 0.5;
227 double ratio = ( new_radius - _radius ) / d ;
229 _center[0] += ( sh.
center()[0] - _center[0] ) * ratio;
230 _center[1] += ( sh.
center()[1] - _center[1] ) * ratio;
231 _center[2] += ( sh.
center()[2] - _center[2] ) * ratio;
233 _radius = new_radius;
245 if (r>_radius) _radius = r;
257template<
typename BBT>
266 for(
unsigned int c=0;c<8;++c)
288template<
typename BBT>
295 for(
unsigned int c=0;c<8;++c)
297 expandRadiusBy(bb.
corner(c));
311#ifdef OSG_USE_FLOAT_BOUNDINGSPHERE
Definition BoundingBox:34
const vec_type center() const
Definition BoundingBox:126
void expandBy(const vec_type &v)
Definition BoundingBox:156
const vec_type corner(unsigned int pos) const
Definition BoundingBox:149
bool valid() const
Definition BoundingBox:86
value_type radius() const
Definition BoundingBox:132
Definition BoundingSphere:35
bool operator!=(const BoundingSphereImpl &rhs) const
Definition BoundingSphere:73
void init()
Definition BoundingSphere:62
BoundingSphereImpl(const BoundingSphereImpl &bs)
Definition BoundingSphere:50
value_type radius2() const
Definition BoundingSphere:96
vec_type & center()
Definition BoundingSphere:83
bool intersects(const BoundingSphereImpl &bs) const
Definition BoundingSphere:139
bool operator==(const BoundingSphereImpl &rhs) const
Definition BoundingSphere:72
bool contains(const vec_type &v) const
Definition BoundingSphere:131
void expandBy(const vector_type &v)
Definition BoundingSphere:149
const vec_type & center() const
Definition BoundingSphere:86
void expandRadiusBy(const vector_type &v)
Definition BoundingSphere:171
value_type _radius
Definition BoundingSphere:41
vec_type _center
Definition BoundingSphere:40
VT vec_type
Definition BoundingSphere:37
VT::value_type value_type
Definition BoundingSphere:38
BoundingSphereImpl(const BoundingBoxImpl< VT > &bb)
Definition BoundingSphere:53
void set(const vec_type ¢er, value_type radius)
Definition BoundingSphere:76
BoundingSphereImpl & operator=(const BoundingSphereImpl &o)
Definition BoundingSphere:55
BoundingSphereImpl(const vec_type &cntr, value_type rad)
Definition BoundingSphere:47
BoundingSphereImpl()
Definition BoundingSphere:44
bool valid() const
Definition BoundingSphere:70
value_type & radius()
Definition BoundingSphere:89
value_type radius() const
Definition BoundingSphere:91
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
BoundingSphered BoundingSphere
Definition BoundingSphere:314
BoundingSphereImpl< Vec3f > BoundingSpheref
Definition BoundingSphere:308
BoundingSphereImpl< Vec3d > BoundingSphered
Definition BoundingSphere:309