Ehm... a couople of small errors.
This commit is contained in:
parent
b7a9093265
commit
4f266201df
|
|
@ -24,6 +24,9 @@
|
||||||
History
|
History
|
||||||
|
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.3 2004/04/02 09:44:13 ponchio
|
||||||
|
Sphere ->Sphere3
|
||||||
|
|
||||||
Revision 1.2 2004/03/25 17:25:46 ponchio
|
Revision 1.2 2004/03/25 17:25:46 ponchio
|
||||||
#include sbagliato.
|
#include sbagliato.
|
||||||
|
|
||||||
|
|
@ -54,8 +57,8 @@ protected:
|
||||||
Point3<T> _center;
|
Point3<T> _center;
|
||||||
T _radius;
|
T _radius;
|
||||||
public:
|
public:
|
||||||
Sphere(): radius(-1) {}
|
Sphere3(): _radius(-1) {}
|
||||||
Sphere(const Point3<T> ¢er, T radius): _center(center), _radius(radius) {}
|
Sphere3(const Point3<T> ¢er, T radius): _center(center), _radius(radius) {}
|
||||||
|
|
||||||
T &Radius() { return _radius; }
|
T &Radius() { return _radius; }
|
||||||
const T &Radius() const { return _radius; }
|
const T &Radius() const { return _radius; }
|
||||||
|
|
@ -74,12 +77,12 @@ public:
|
||||||
typedef Sphere3<float> Sphere3f;
|
typedef Sphere3<float> Sphere3f;
|
||||||
typedef Sphere3<double> Sphere3d;
|
typedef Sphere3<double> Sphere3d;
|
||||||
|
|
||||||
template <class T> void Sphere<T>::Add(const Sphere<T> &sphere) {
|
template <class T> void Sphere3<T>::Add(const Sphere3<T> &sphere) {
|
||||||
if(IsEmpty()) {
|
if(IsEmpty()) {
|
||||||
*this = sphere;
|
*this = sphere;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Point3<T> dist = sphere.center - _center;
|
Point3<T> dist = sphere.Center() - _center;
|
||||||
float distance = dist.Norm();
|
float distance = dist.Norm();
|
||||||
float fartest = distance + sphere.Radius();
|
float fartest = distance + sphere.Radius();
|
||||||
|
|
||||||
|
|
@ -93,7 +96,7 @@ template <class T> void Sphere<T>::Add(const Sphere<T> &sphere) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void Sphere<T>::Add(Point3<T> &p) {
|
template <class T> void Sphere3<T>::Add(Point3<T> &p) {
|
||||||
if(IsEmpty()) {
|
if(IsEmpty()) {
|
||||||
_center = p;
|
_center = p;
|
||||||
_radius = 0;
|
_radius = 0;
|
||||||
|
|
@ -105,7 +108,7 @@ template <class T> void Sphere<T>::Add(Point3<T> &p) {
|
||||||
_radius = (_radius + fartest)/2;
|
_radius = (_radius + fartest)/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool Sphere<T>::IsIn(const Point3<T> &p) const {
|
template <class T> bool Sphere3<T>::IsIn(const Point3<T> &p) const {
|
||||||
Point3<T> dist = p - _center;
|
Point3<T> dist = p - _center;
|
||||||
return dist.Norm() <= _radius;
|
return dist.Norm() <= _radius;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue