DGtal  1.0.0
Knot_5_2.ih
1 /**
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.
6  *
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.
11  *
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/>.
14  *
15  **/
16 
17 /**
18  * @file Knot_5_2.ih
19  * @author Kacper Pluta (\c kacper.pluta@esiee.fr )
20  * Laboratoire d'Informatique Gaspard-Monge - LIGM, A3SI, France
21  *
22  * @date 2014/10/01
23  *
24  * Implementation of inline methods defined in Knot_5_2.h
25  *
26  * This file is part of the DGtal library.
27  */
28 
29 ///////////////////////////////////////////////////////////////////////////////
30 // IMPLEMENTATION of inline methods.
31 ///////////////////////////////////////////////////////////////////////////////
32 
33 //////////////////////////////////////////////////////////////////////////////
34 //////////////////////////////////////////////////////////////////////////////
35 
36 
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 // Implementation of inline methods //
40 
41 template <typename T>
42 inline
43 DGtal::Knot_5_2<T>::Knot_5_2 ( long double scale_1, long double scale_2, long double scale_3 ) : scale {scale_1, scale_2, scale_3}
44 {}
45 
46 template < typename T>
47 inline
48 typename DGtal::Knot_5_2<T>::RealPoint DGtal::Knot_5_2<T>::x ( const long double t ) const
49 {
50  return RealPoint ( scale[0] * std::cos ( 2. * t ) * ( 3. + std::cos ( 5. * t ) ),
51  scale[1] * std::sin ( 2. * t ) * ( 3. + std::cos ( 5. * t ) ),
52  scale[2] * std::sin( 5. * t )
53  );
54 }
55 
56 template < typename T>
57 inline
58 typename DGtal::Knot_5_2<T>::RealPoint DGtal::Knot_5_2<T>::xp ( const long double t ) const
59 {
60  return RealPoint ( scale[0] * -1. /2. * ( 12. * std::sin ( 2 * t ) + 3. * std::sin ( 3. * t ) + 7. * std::sin ( 7. * t ) ),
61  scale[1] * 1. / 2. * ( 12. * std::cos ( 2. * t ) - 3. * std::cos ( 3. * t ) + 7. * std::cos ( 7. * t ) ),
62  scale[2] * 5. * std::cos( 5. * t ) );
63 }
64 
65 
66 template < typename T>
67 inline
68 double DGtal::Knot_5_2<T>::getPeriod()
69 {
70  return PERIOD;
71 }
72 
73 template < typename T>
74 inline
75 void DGtal::Knot_5_2<T>::selfDisplay ( std::ostream & out ) const
76 {
77  out << "[Knot_5_2]";
78 }
79 
80 ///////////////////////////////////////////////////////////////////////////////
81 // Implementation of inline functions and external operators //
82 
83 /**
84  * Overloads 'operator<<' for displaying objects of class 'Knot_5_2'.
85  * @param out the output stream where the object is written.
86  * @param object the object of class 'Knot_5_2' to write.
87  * @return the output stream after the writing.
88  */
89 template <typename T>
90 inline
91 std::ostream&
92 DGtal::operator<< ( std::ostream & out, const Knot_5_2<T> & object )
93 {
94  object.selfDisplay ( out );
95  return out;
96 }
97 
98 // //
99 ///////////////////////////////////////////////////////////////////////////////
100 
101