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 ClosedIntegerHalfPlane.ih
19 * @author Jacques-Olivier Lachaud (\c jacques-olivier.lachaud@univ-savoie.fr )
20 * Laboratory of Mathematics (CNRS, UMR 5127), University of Savoie, France
24 * Implementation of inline methods defined in ClosedIntegerHalfPlane.h
26 * This file is part of the DGtal library.
30 //////////////////////////////////////////////////////////////////////////////
32 //////////////////////////////////////////////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////////
35 // IMPLEMENTATION of inline methods.
36 ///////////////////////////////////////////////////////////////////////////////
38 ///////////////////////////////////////////////////////////////////////////////
39 // ----------------------- Standard services ------------------------------
41 //-----------------------------------------------------------------------------
42 template <typename TSpace>
44 DGtal::ClosedIntegerHalfPlane<TSpace>::
45 ClosedIntegerHalfPlane( const Vector & aN, const Integer & aC )
48 //-----------------------------------------------------------------------------
49 template <typename TSpace>
52 DGtal::ClosedIntegerHalfPlane<TSpace>::
53 operator()( const Point & p ) const
55 return N.dot( p ) <= c;
57 //-----------------------------------------------------------------------------
58 template <typename TSpace>
61 DGtal::ClosedIntegerHalfPlane<TSpace>::
62 isOnBoundary( const Point & p ) const
64 return N.dot( p ) == c;
66 //-----------------------------------------------------------------------------
67 template <typename TSpace>
69 typename DGtal::ClosedIntegerHalfPlane<TSpace>::Vector
70 DGtal::ClosedIntegerHalfPlane<TSpace>::
73 return Vector( -N[ 1 ], N[ 0 ] );
75 //-----------------------------------------------------------------------------
76 template <typename TSpace>
79 DGtal::ClosedIntegerHalfPlane<TSpace>::
82 N.negate(); // = Point( -N[ 0 ], -N[ 1 ] );
85 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
87 template <typename TSpace>
89 DGtal::ClosedIntegerHalfPlane<TSpace>::
90 ClosedIntegerHalfPlane( const Point & A, const Point & B,
91 const Point & inP, IntegerComputer<Integer> & ic )
93 N[ 0 ] = A[ 1 ] - B[ 1 ];
94 N[ 1 ] = B[ 0 ] - A[ 0 ];
95 ic.getDotProduct( c, N, A );
97 ic.getDotProduct( c1, N, inP );
103 //simplification of the constraint
104 Integer g = ic.gcd( N[ 0 ], N[ 1 ] );
109 ///////////////////////////////////////////////////////////////////////////////
110 // Interface - public :
113 * Writes/Displays the object on an output stream.
114 * @param out the output stream where the object is written.
116 template <typename TSpace>
119 DGtal::ClosedIntegerHalfPlane<TSpace>::selfDisplay ( std::ostream & out ) const
121 out << "[ClosedIntegerHalfPlane N=" << N << " c=" << c << " ]";
125 * Checks the validity/consistency of the object.
126 * @return 'true' if the object is valid, 'false' otherwise.
128 template <typename TSpace>
131 DGtal::ClosedIntegerHalfPlane<TSpace>::isValid() const
138 ///////////////////////////////////////////////////////////////////////////////
139 // Implementation of inline functions //
141 template <typename TSpace>
144 DGtal::operator<< ( std::ostream & out,
145 const ClosedIntegerHalfPlane<TSpace> & object )
147 object.selfDisplay( out );
152 ///////////////////////////////////////////////////////////////////////////////