32#ifndef DVD_CORE_MATH_BOUNDINGVOLUMES_BOUNDINGSPHERE_INL_
33#define DVD_CORE_MATH_BOUNDINGVOLUMES_BOUNDINGSPHERE_INL_
38 _center.set(bBox.getCenter());
39 _radius = (bBox.getMax() - _center).length();
43 _center.set(bSphere.getCenter());
44 _radius = bSphere.getRadius();
49 const F32 dist = (bSphere._center - _center).length();
51 if (_radius >= dist + bSphere._radius) {
55 if (bSphere._radius >= dist + _radius) {
56 _center = bSphere._center;
57 _radius = bSphere._radius;
61 const F32 nRadius = (_radius + dist + bSphere._radius) * 0.5f;
62 const F32 ratio = (nRadius - _radius) / dist;
63 _center += (bSphere._center - _center) * ratio;
70 const F32 dist = (bSphere._center - _center).length() + bSphere._radius;
80 const F32 nRadius = (dist - _radius) * 0.5f;
81 _center += diff * (nRadius / dist);
87 const F32 dist = (point - _center).length();
95 const F32 numPoints =
to_F32(points.size());
98 _center += p / numPoints;
102 const F32 distance = (p - _center).length();
104 if (distance > _radius) {
118 const F32 distance = (p - _center).length();
120 if (distance > _radius) {
147 return getCenter().distance(point) - getRadius();
152 return std::max(getCenter().distanceSquared(point) -
SQUARED(getRadius()), 0.f);
void fromBoundingBox(const BoundingBox &bBox) noexcept
void addRadius(const BoundingSphere &bSphere) noexcept
void createFromPoints(const vector< vec3< F32 > > &points) noexcept
const vec3< F32 > & getCenter() const noexcept
F32 getDistanceFromPoint(const vec3< F32 > &point) const noexcept
void fromBoundingSphere(const BoundingSphere &bSphere) noexcept
void setRadius(F32 radius) noexcept
F32 getRadius() const noexcept
vec4< F32 > asVec4() const noexcept
void add(const BoundingSphere &bSphere) noexcept
F32 getDiameter() const noexcept
void setCenter(const vec3< F32 > ¢er) noexcept
F32 getDistanceSQFromPoint(const vec3< F32 > &point) const noexcept
T length() const noexcept
return the vector's length
void reset() noexcept
set all the components back to 0
Handle console commands that start with a forward slash.
constexpr T SQUARED(T input) noexcept
constexpr F32 to_F32(const T value)
constexpr F32 EPSILON_F32
eastl::vector< Type > vector