source: projectionDesigner/trunk/projdesigner/include/gmtl/Sphere.h @ 16

Last change on this file since 16 was 4, checked in by Torben Dannhauer, 15 years ago
File size: 3.4 KB
RevLine 
[4]1/************************************************************** ggt-head beg
2 *
3 * GGT: Generic Graphics Toolkit
4 *
5 * Original Authors:
6 *   Allen Bierbaum
7 *
8 * -----------------------------------------------------------------
9 * File:          Sphere.h,v
10 * Date modified: 2002/05/20 22:39:22
11 * Version:       1.5
12 * -----------------------------------------------------------------
13 *
14 *********************************************************** ggt-head end */
15/*************************************************************** ggt-cpr beg
16*
17* GGT: The Generic Graphics Toolkit
18* Copyright (C) 2001,2002 Allen Bierbaum
19*
20* This library is free software; you can redistribute it and/or
21* modify it under the terms of the GNU Lesser General Public
22* License as published by the Free Software Foundation; either
23* version 2.1 of the License, or (at your option) any later version.
24*
25* This library is distributed in the hope that it will be useful,
26* but WITHOUT ANY WARRANTY; without even the implied warranty of
27* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28* Lesser General Public License for more details.
29*
30* You should have received a copy of the GNU Lesser General Public
31* License along with this library; if not, write to the Free Software
32* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33*
34 ************************************************************ ggt-cpr end */
35#ifndef _GMTL_SPHERE_H_
36#define _GMTL_SPHERE_H_
37
38#include <gmtl/Point.h>
39
40namespace gmtl
41{
42
43/**
44 * Describes a sphere in 3D space by its center point and its radius.
45 *
46 * @param DATA_TYPE     the internal type used for the point and radius
47 * @ingroup Types
48 */
49template<class DATA_TYPE>
50class Sphere
51{
52public:
53   typedef DATA_TYPE DataType;
54
55public:
56   /**
57    * Constructs a sphere centered at the origin with a radius of 0.
58    */
59   Sphere()
60      : mRadius( 0 )
61   {}
62
63   /**
64    * Constructs a sphere with the given center and radius.
65    *
66    * @param center     the point at which to center the sphere
67    * @param radius     the radius of the sphere
68    */
69   Sphere( const Point<DATA_TYPE, 3>& center, const DATA_TYPE& radius )
70      : mCenter( center ), mRadius( radius )
71   {}
72
73   /**
74    * Constructs a duplicate of the given sphere.
75    *
76    * @param sphere     the sphere to make a copy of
77    */
78   Sphere( const Sphere<DATA_TYPE>& sphere )
79      : mCenter( sphere.mCenter ), mRadius( sphere.mRadius )
80   {}
81
82   /**
83    * Gets the center of the sphere.
84    *
85    * @return  the center point of the sphere
86    */
87   const Point<DATA_TYPE, 3>& getCenter() const
88   {
89      return mCenter;
90   }
91
92   /**
93    * Gets the radius of the sphere.
94    *
95    * @return  the radius of the sphere
96    */
97   const DATA_TYPE& getRadius() const
98   {
99      return mRadius;
100   }
101
102   /**
103    * Sets the center point of the sphere.
104    *
105    * @param center     the new point at which to center the sphere
106    */
107   void setCenter( const Point<DATA_TYPE, 3>& center )
108   {
109      mCenter = center;
110   }
111
112   /**
113    * Sets the radius of the sphere.
114    *
115    * @param radius     the new radius of the sphere
116    */
117   void setRadius( const DATA_TYPE& radius )
118   {
119      mRadius = radius;
120   }
121
122public:
123   /**
124    * The center of the sphere.
125    */
126   Point<DATA_TYPE, 3> mCenter;
127
128   /**
129    * The radius of the sphere.
130    */
131   DATA_TYPE mRadius;
132};
133
134// --- helper types --- //
135typedef Sphere<float>   Spheref;
136typedef Sphere<double>  Sphered;
137
138};
139
140#endif
Note: See TracBrowser for help on using the repository browser.