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/>.
18 * @file EllipticHelix.ih
19 * @author Kacper Pluta (\c kacper.pluta@esiee.fr )
20 * Laboratoire d'Informatique Gaspard-Monge - LIGM, A3SI, France
24 * Implementation of inline methods defined in EllipticHelix.h
26 * This file is part of the DGtal library.
29 ///////////////////////////////////////////////////////////////////////////////
30 // IMPLEMENTATION of inline methods.
31 ///////////////////////////////////////////////////////////////////////////////
33 //////////////////////////////////////////////////////////////////////////////
34 //////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
39 // Implementation of inline methods //
43 DGtal::EllipticHelix<T>::EllipticHelix ( long double rr, long double rl, long double bb ) : r1 ( rr ), r2 ( rl ) , b ( bb ) {}
45 template < typename T>
47 typename DGtal::EllipticHelix<T>::RealPoint DGtal::EllipticHelix<T>::x ( const long double t ) const
49 return RealPoint ( r1 * std::cos ( t ), r2 * std::sin ( t ), b * t );
52 template < typename T>
54 typename DGtal::EllipticHelix<T>::RealPoint DGtal::EllipticHelix<T>::xp ( const long double t ) const
56 return RealPoint ( -r1 * std::sin ( t ), r2 * std::cos ( t ), b );
59 template < typename T>
61 long double DGtal::EllipticHelix<T>:: f ( const RealPoint & p ) const
65 long double value = std::acos ( p[0] / r1 );
66 if ( std::isnan ( value ) )
67 throw std::runtime_error ( "Out of range!" );
72 long double value = std::acos ( p[0] / r1 );
73 if ( std::isnan ( value ) )
74 throw std::runtime_error ( "Out of range!" );
75 return 2.0 * M_PI - value;
78 throw std::runtime_error ( "Out of range!" );
81 template < typename T>
83 long double DGtal::EllipticHelix<T>:: g ( const RealPoint & p ) const
85 if ( p[0] >= 0. && p[1] >= 0. )
87 long double value = std::asin ( p[1] / r2 );
88 if ( std::isnan ( value ) )
89 throw std::runtime_error ( "Out of range!" );
94 long double value = std::asin ( p[1] / r2 );
95 if ( std::isnan ( value ) )
96 throw std::runtime_error ( "Out of range!" );
99 else if ( p[0] >= 0. && p[1] < 0. )
101 long double value = std::asin ( p[1]/ r2 );
102 if ( std::isnan ( value ) )
103 throw std::runtime_error ( "Out of range!" );
104 return 2. * M_PI + value;
107 throw std::runtime_error ( "Out of range!" );
110 template < typename T>
112 long double DGtal::EllipticHelix<T>:: h ( const RealPoint & p ) const
114 if ( std::abs ( b ) < 1E-20 )
120 template < typename T>
122 double DGtal::EllipticHelix<T>::getPeriod()
128 template < typename T>
130 void DGtal::EllipticHelix<T>::selfDisplay ( std::ostream & out ) const
132 out << "[EllipticHelix]";
135 ///////////////////////////////////////////////////////////////////////////////
136 // Implementation of inline functions and external operators //
139 * Overloads 'operator<<' for displaying objects of class 'EllipticHelix'.
140 * @param out the output stream where the object is written.
141 * @param object the object of class 'EllipticHelix' to write.
142 * @return the output stream after the writing.
144 template <typename T>
147 DGtal::operator<< ( std::ostream & out,
148 const EllipticHelix<T> & object )
150 object.selfDisplay ( out );
155 ///////////////////////////////////////////////////////////////////////////////