CrystalSpace

Public API Reference

csgeom/sphere.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2001 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_SPHERE_H__
00020 #define __CS_SPHERE_H__
00021 
00029 #include "csextern.h"
00030 
00031 #include "cstypes.h"
00032 #include "vector3.h"
00033 
00034 class csTransform;
00035 
00039 class CS_CRYSTALSPACE_EXPORT csSphere
00040 {
00041 private:
00042   csVector3 center;
00043   float radius;
00044 
00045 public:
00047   csSphere ()
00048   {
00049     center.Set (0, 0, 0);
00050     radius = 0;
00051   }
00052 
00054   csSphere (const csVector3& center, float radius)
00055   {
00056     csSphere::center = center;
00057     csSphere::radius = radius;
00058   }
00059 
00061   csSphere (const csSphere& s) { center = s.center; radius = s.radius; }
00062 
00064   inline csVector3& GetCenter () { return center; }
00066   inline const csVector3& GetCenter () const { return center; }
00068   inline void SetCenter (const csVector3& c) { center = c; }
00070   inline float GetRadius () const { return radius; }
00072   inline void SetRadius (float r) { radius = r; }
00073 
00075   void Union (const csVector3& ocenter, float oradius);
00076 
00078   friend csSphere operator+ (const csSphere& s1, const csSphere& s2);
00080   csSphere& operator+= (const csSphere& s)
00081   {
00082     Union (s.center, s.radius);
00083     return *this;
00084   }
00085 };
00086 
00090 class CS_CRYSTALSPACE_EXPORT csEllipsoid
00091 {
00092 private:
00093   csVector3 center;
00094   csVector3 radius;
00095 
00096 public:
00098   csEllipsoid ()
00099   {
00100     center.Set (0, 0, 0);
00101     radius.Set (0, 0, 0);
00102   }
00103 
00105   csEllipsoid (const csVector3& center, const csVector3& radius)
00106   {
00107     csEllipsoid::center = center;
00108     csEllipsoid::radius = radius;
00109   }
00110 
00112   csEllipsoid (const csEllipsoid& s) { center = s.center; radius = s.radius; }
00113 
00115   inline csVector3& GetCenter () { return center; }
00117   inline const csVector3& GetCenter () const { return center; }
00119   inline void SetCenter (const csVector3& c) { center = c; }
00121   inline csVector3& GetRadius () { return radius; }
00123   inline const csVector3& GetRadius () const { return radius; }
00125   inline void SetRadius (const csVector3& r) { radius = r; }
00126 };
00127 
00130 #endif // __CS_SPHERE_H__
00131 

Generated for Crystal Space by doxygen 1.4.7