2 * This program is free software: you can redistribute it and/or modify
3 * it under the terms of the GNU Lesser General Public License as
4 * published by the Free Software Foundation, either version 3 of the
5 * License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @author David Coeurjolly (\c david.coeurjolly@liris.cnrs.fr )
20 * Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
24 * Implementation of inline methods defined in Ball2D.h
26 * This file is part of the DGtal library.
30 //////////////////////////////////////////////////////////////////////////////
32 //////////////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
39 // ----------------------- Standard services ------------------------------
46 DGtal::Ball2D<T>::~Ball2D()
52 DGtal::Ball2D<T>::Ball2D(const double x0, const double y0, const double radius):
53 myRadius(radius), myCenter(x0,y0)
59 DGtal::Ball2D<T>::Ball2D(const RealPoint2D &aPoint, const double radius):
60 myRadius(radius), myCenter(aPoint)
65 DGtal::Ball2D<T>::Ball2D(const Point &aPoint, const double radius):
71 /////////////////////////////////////////////////////////////////////////////
72 // ------------- Implementation of 'StarShaped' services ------------------
75 * @param p any point in the plane.
77 * @return the angle parameter between 0 and 2*Pi corresponding to
78 * this point for the shape.
83 DGtal::Ball2D<T>::parameter( const RealPoint2D & pp ) const
88 double angle = atan2( p[1], p[0] );
89 angle = ( angle < 0.0 ) ? angle + 2*M_PI : angle;
95 * @param t any angle between 0 and 2*Pi.
97 * @return the vector (x(t),y(t)) which is the position on the
100 template <typename T>
102 typename DGtal::Ball2D<T>::RealPoint2D
103 DGtal::Ball2D<T>::x( double t ) const
105 RealPoint2D c( myRadius*cos(t), myRadius*sin(t) );
112 * @param t any angle between 0 and 2*Pi.
114 * @return the vector (x'(t),y'(t)) which is the tangent to the
117 template <typename T>
119 typename DGtal::Ball2D<T>::RealVector2D
120 DGtal::Ball2D<T>::xp( const double t ) const
122 RealVector2D c( -myRadius*sin(t), myRadius*cos(t) );
127 * @param t any angle between 0 and 2*Pi.
129 * @return the vector (x''(t),y''(t)).
131 template <typename T>
133 typename DGtal::Ball2D<T>::RealVector2D
134 DGtal::Ball2D<T>::xpp( const double t ) const
136 RealVector2D c( -myRadius*cos(t), -myRadius*sin(t) );
141 ///////////////////////////////////////////////////////////////////////////////
142 // Interface - public :
145 * Writes/Displays the object on an output stream.
146 * @param out the output stream where the object is written.
148 template <typename T>
151 DGtal::Ball2D<T>::selfDisplay ( std::ostream & out ) const
153 out << "[Ball2D] center= "<<myCenter<<" radius="<<myRadius;
157 * Checks the validity/consistency of the object.
158 * @return 'true' if the object is valid, 'false' otherwise.
160 template <typename T>
163 DGtal::Ball2D<T>::isValid() const
170 ///////////////////////////////////////////////////////////////////////////////
171 // Implementation of inline functions //
173 template <typename T>
176 DGtal::operator<< ( std::ostream & out,
177 const Ball2D<T> & object )
179 object.selfDisplay( out );
184 ///////////////////////////////////////////////////////////////////////////////