如何计算封装另外两个球体的最小球体?
每个球体在3d空间和半径中都有一个中心点。
编辑:
这是我的代码。我试图实现merge()函数,但我不知道如何。
#include <gl\glm\glm.hpp>
class Sphere
{
public:
Sphere();
Sphere(const glm::vec3 &point, float radius);
void set(const glm::vec3 &point, float radius);
void reset();
bool isReset() const;
const glm::vec3& getCenter() const { return _point; }
float radius() const { return _radius; }
void merge(const Sphere &other);
bool operator==(const Sphere &other) const {
return (_point == other._point && _radius == other._radius);
}
bool operator!=(const Sphere &other) const {
return !operator==(other);
}
private:
glm::vec3 _point;
float _radius;
};