DGtal  1.5.beta
InHalfPlaneBySimple3x3Matrix.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 InHalfPlaneBySimple3x3Matrix.ih
19  * @author Tristan Roussillon (\c tristan.roussillon@liris.cnrs.fr )
20  * Laboratoire d'InfoRmatique en Image et Systèmes d'information - LIRIS (CNRS, UMR 5205), CNRS, France
21  *
22  * @date 2013/11/22
23  *
24  * Implementation of inline methods defined in InHalfPlaneBySimple3x3Matrix.h
25  *
26  * This file is part of the DGtal library.
27  */
28 
29 
30 //////////////////////////////////////////////////////////////////////////////
31 #include <cstdlib>
32 //////////////////////////////////////////////////////////////////////////////
33 
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
37 
38 ///////////////////////////////////////////////////////////////////////////////
39 // ----------------------------------------------------------------------------
40 template <typename TP, typename TI>
41 inline
42 void
43 DGtal::InHalfPlaneBySimple3x3Matrix<TP,TI>::init( const Point& aP, const Point& aQ )
44 {
45  myMatrix.setComponent( 0, 0, static_cast<Integer>( aP[0] ) );
46  myMatrix.setComponent( 0, 1, static_cast<Integer>( aP[1] ) );
47  myMatrix.setComponent( 0, 2, NumberTraits<Integer>::ONE );
48  myMatrix.setComponent( 1, 0, static_cast<Integer>( aQ[0] ) );
49  myMatrix.setComponent( 1, 1, static_cast<Integer>( aQ[1] ) );
50  myMatrix.setComponent( 1, 2, NumberTraits<Integer>::ONE );
51 }
52 
53 // ----------------------------------------------------------------------------
54 template <typename TP, typename TI>
55 inline
56 void
57 DGtal::InHalfPlaneBySimple3x3Matrix<TP,TI>::init( const PointArray& aA )
58 {
59  init( aA[0], aA[1] );
60 }
61 
62 // ----------------------------------------------------------------------------
63 template <typename TP, typename TI>
64 inline
65 typename DGtal::InHalfPlaneBySimple3x3Matrix<TP,TI>::Value
66 DGtal::InHalfPlaneBySimple3x3Matrix<TP,TI>::operator()( const Point& aR ) const
67 {
68  myMatrix.setComponent( 2, 0, static_cast<Integer>( aR[0] ) );
69  myMatrix.setComponent( 2, 1, static_cast<Integer>( aR[1] ) );
70  myMatrix.setComponent( 2, 2, NumberTraits<Integer>::ONE );
71  return myMatrix.determinant();
72 }
73 
74 // ----------------------------------------------------------------------------
75 template <typename TP, typename TI>
76 inline
77 void
78 DGtal::InHalfPlaneBySimple3x3Matrix<TP,TI>::selfDisplay ( std::ostream & out ) const
79 {
80  out << "[InHalfPlaneBySimple3x3Matrix]";
81 }
82 
83 // ----------------------------------------------------------------------------
84 template <typename TP, typename TI>
85 inline
86 bool
87 DGtal::InHalfPlaneBySimple3x3Matrix<TP,TI>::isValid() const
88 {
89  return true;
90 }
91 
92 
93 
94 ///////////////////////////////////////////////////////////////////////////////
95 // Implementation of inline functions //
96 
97 template <typename TP, typename TI>
98 inline
99 std::ostream&
100 DGtal::operator<< ( std::ostream & out,
101  const InHalfPlaneBySimple3x3Matrix<TP,TI> & object )
102 {
103  object.selfDisplay( out );
104  return out;
105 }
106 
107 // //
108 ///////////////////////////////////////////////////////////////////////////////
109 
110