00001 // llsphere.h 00024 #ifndef LL_SPHERE_H 00025 #define LL_SPHERE_H 00026 00027 #include "stdtypes.h" 00028 #include "v3math.h" 00029 #include <iostream> 00030 #include <vector> 00031 00032 class LLSphere 00033 { 00034 public: 00035 LLSphere(); 00036 LLSphere( const LLVector3& center, F32 radius ); 00037 00038 void set( const LLVector3& center, F32 radius ); 00039 void setCenter( const LLVector3& center ); 00040 void setRadius( F32 radius ); 00041 00042 const LLVector3& getCenter() const; 00043 F32 getRadius() const; 00044 00045 // returns TRUE if this sphere completely contains other_sphere 00046 BOOL contains(const LLSphere& other_sphere) const; 00047 00048 // returns TRUE if this sphere overlaps other_sphere 00049 BOOL overlaps(const LLSphere& other_sphere) const; 00050 00051 // returns overlap distance 00052 // negative overlap is closest approach 00053 F32 getOverlap(const LLSphere& other_sphere) const; 00054 00055 // removes any spheres that are contained in others 00056 static void collapse(std::vector<LLSphere>& sphere_list); 00057 00058 // returns minimum sphere bounding sphere for a set of spheres 00059 static LLSphere getBoundingSphere(const LLSphere& first_sphere, const LLSphere& second_sphere); 00060 static LLSphere getBoundingSphere(const std::vector<LLSphere>& sphere_list); 00061 00062 bool operator==(const LLSphere& rhs) const; 00063 00064 friend std::ostream& operator<<( std::ostream& output_stream, const LLSphere& line ); 00065 00066 protected: 00067 LLVector3 mCenter; 00068 F32 mRadius; 00069 }; 00070 00071 00072 #endif