sphere_3d.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_SPHERE_3D_H
00054 #define LASS_GUARDIAN_OF_INCLUSION_PRIM_SPHERE_3D_H
00055
00056
00057
00058
00059
00060
00061 #include "prim_common.h"
00062 #include "point_3d.h"
00063
00064
00065
00066
00067
00068 namespace lass
00069 {
00070
00071 namespace prim
00072 {
00073
00074 template<typename T>
00075 class Sphere3D
00076 {
00077 public:
00078
00079 typedef Sphere3D<T> TSelf;
00080
00081 typedef Point3D<T> TPoint;
00082 typedef typename TPoint::TVector TVector;
00083
00084 typedef typename TPoint::TValue TValue;
00085 typedef typename TPoint::TParam TParam;
00086 typedef typename TPoint::TReference TReference;
00087 typedef typename TPoint::TConstReference TConstReference;
00088 typedef typename TPoint::TNumTraits TNumTraits;
00089
00090 enum { dimension = TPoint::dimension };
00091
00092 template <typename U> struct Rebind
00093 {
00094 typedef Sphere3D<U> Type;
00095 };
00096
00097 Sphere3D();
00098 Sphere3D(const Point3D<T>& iCenter, TParam iRadius);
00099
00100 const TPoint& center() const;
00101 TPoint& center();
00102
00103 TConstReference radius() const;
00104 TReference radius();
00105
00106 const TValue area() const;
00107 const TValue volume() const;
00108
00109 const Side classify(const TPoint& iPoint) const;
00110 const TValue equation(const TPoint& iPoint) const;
00111 const TValue signedDistance(const TPoint& iPoint) const;
00112 const TValue squaredDistance(const TPoint& iPoint) const;
00113 const bool contains(const TPoint& iPoint) const;
00114
00115 const Side classify(const TPoint& iPoint, TParam iRelativeTolerance) const;
00116 const TValue equation(const TPoint& iPoint, TParam iRelativeTolerance) const;
00117 const TValue signedDistance(const TPoint& iPoint, TParam iRelativeTolerance) const;
00118 const TValue squaredDistance(const TPoint& iPoint, TParam iRelativeTolerance) const;
00119 const bool contains(const TPoint& iPoint, TParam iRelativeTolerance) const;
00120
00121 const bool isValid() const;
00122
00123 private:
00124
00125 TPoint center_;
00126 TValue radius_;
00127 };
00128
00129 template <typename T> const T squaredDistance(const Sphere3D<T>& sphere, const Point3D<T>& point);
00130 template <typename T> const T distance(const Sphere3D<T>& sphere, const Point3D<T>& point);
00131
00132 template<typename T> std::ostream& operator<<(std::ostream& oOStream, const Sphere3D<T>& iB);
00133 template <typename T> io::XmlOStream& operator<<(io::XmlOStream& ioOStream, const Sphere3D<T>& iB);
00134
00135 }
00136
00137 }
00138
00139 #include "sphere_3d.inl"
00140
00141 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_3D_H
00142 # include "aabb_3d_sphere_3d.h"
00143 #endif
00144
00145 #ifdef LASS_GUARDIAN_OF_INCLUSION_PRIM_RAY_3D_H
00146 #include "ray_3d_sphere_3d.h"
00147 #endif
00148
00149 #endif
00150
00151