// ============================================================================ // // Copyright (c) 1997-2001 The CGAL Consortium // // This software and related documentation is part of an INTERNAL release // of the Computational Geometry Algorithms Library (CGAL). It is not // intended for general use. // // ---------------------------------------------------------------------------- // // release : $CGAL_Revision: CGAL-I $ // release_date : $CGAL_Date$ // // file : include/CGAL/Optimisation_circle_2.h // package : $CGAL_Package: Min_circle_2 $ // chapter : Geometric Optimisation // // source : web/Min_circle_2.aw // revision : $Revision$ // revision_date : $Date$ // // author(s) : Sven Schönherr , Bernd Gärtner // coordinator : ETH Zürich (Bernd Gärtner ) // // implementation: 2D Optimisation Circle // ============================================================================ #ifndef CGAL_OPTIMISATION_CIRCLE_2_H #define CGAL_OPTIMISATION_CIRCLE_2_H // includes #ifndef CGAL_POINT_2_H # include #endif #ifndef CGAL_BASIC_CONSTRUCTIONS_2_H # include #endif #ifndef CGAL_SQUARED_DISTANCE_2_H # include #endif CGAL_BEGIN_NAMESPACE // Class declaration // ================= template < class K_ > class Optimisation_circle_2; // Class interface // =============== template < class K_ > class Optimisation_circle_2 { public: // types typedef K_ K; typedef CGAL::Point_2 Point; typedef typename K_::FT Distance; /************************************************************************** WORKAROUND: Some compilers are unable to match member functions defined outside the class template. Therefore, all member functions are implemented in the class interface. // creation Optimisation_circle_2( ); void set( ); void set( const Point& p); void set( const Point& p, const Point& q); void set( const Point& p, const Point& q, const Point& r); void set( const Point& center, const Distance& squared_radius); // access functions const Point& center ( ) const; const Distance& squared_radius( ) const // equality tests bool operator == ( const Optimisation_circle_2& c) const; bool operator != ( const Optimisation_circle_2& c) const; // predicates CGAL::Bounded_side bounded_side( const Point& p) const; bool has_on_bounded_side ( const Point& p) const; bool has_on_boundary ( const Point& p) const; bool has_on_unbounded_side ( const Point& p) const; bool is_empty ( ) const; bool is_degenerate( ) const; **************************************************************************/ private: // private data members Point _center; Distance _squared_radius; // ============================================================================ // Class implementation // ==================== public: // Constructor // ----------- inline Optimisation_circle_2( ) { } // Set functions // ------------- inline void set( ) { _center = Point( CGAL::ORIGIN); _squared_radius = -Distance( 1); } inline void set( const Point& p) { _center = p; _squared_radius = Distance( 0); } inline void set( const Point& p, const Point& q) { _center = CGAL::midpoint( p, q); _squared_radius = CGAL::squared_distance( p, _center); } inline void set( const Point& p, const Point& q, const Point& r) { _center = CGAL::circumcenter( p, q, r); _squared_radius = CGAL::squared_distance( p, _center); } inline void set( const Point& center, const Distance& squared_radius) { _center = center; _squared_radius = squared_radius; } // Access functions // ---------------- inline const Point& center( ) const { return( _center); } inline const Distance& squared_radius( ) const { return( _squared_radius); } // Equality tests // -------------- bool operator == ( const Optimisation_circle_2& c) const { return( ( _center == c._center ) && ( _squared_radius == c._squared_radius) ); } bool operator != ( const Optimisation_circle_2& c) const { return( ! operator==( c)); } // Predicates // ---------- inline CGAL::Bounded_side bounded_side( const Point& p) const { return( CGAL::Bounded_side( CGAL_NTS sign( _squared_radius - CGAL::squared_distance( p, _center)))); } inline bool has_on_bounded_side( const Point& p) const { return( CGAL::squared_distance( p, _center) < _squared_radius); } inline bool has_on_boundary( const Point& p) const { return( CGAL::squared_distance( p, _center) == _squared_radius); } inline bool has_on_unbounded_side( const Point& p) const { return( _squared_radius < CGAL::squared_distance( p, _center)); } inline bool is_empty( ) const { return( CGAL::is_negative( _squared_radius)); } inline bool is_degenerate( ) const { return( ! CGAL::is_positive( _squared_radius)); } }; // Function declarations // ===================== // I/O // --- template < class K_ > std::ostream& operator << ( std::ostream&, const CGAL::Optimisation_circle_2&); template < class K_ > std::istream& operator >> ( std::istream&, CGAL::Optimisation_circle_2&); CGAL_END_NAMESPACE #ifdef CGAL_CFG_NO_AUTOMATIC_TEMPLATE_INCLUSION # include #endif #endif // CGAL_OPTIMISATION_CIRCLE_2_H // ===== EOF ==================================================================