Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Traits Class Adapter for 2D Smallest Enclosing Circle to 2D Homogeneous Points (Min_circle_2_adapterH2)

Definition

The class Min_circle_2_adapterH2<PT,DA> interfaces the 2D optimisation algorithm for smallest enclosing circles with the point class PT. The data accessor DA [KW97] is used to access the hx-, hy- and hw-coordinate of PT, i.e. PT is supposed to have a homogeneous representation of its coordinates.

#include <CGAL/Min_circle_2_adapterH2.h>

Types

Min_circle_2_adapterH2<PT,DA>::DA
Data accessor for homogeneous coordinates.


Min_circle_2_adapterH2<PT,DA>::Point
Point type.


Min_circle_2_adapterH2<PT,DA>::Circle
Circle type.

Creation

Min_circle_2_adapterH2<PT,DA> adapter ( DA da = DA());

Min_circle_2_adapterH2<PT,DA> adapter ( Min_circle_2_adapterH2<PT,DA>);

Operations

Orientation adapter.orientation ( Point p, Point q, Point r)
returns constants LEFTTURN, COLLINEAR, or RIGHTTURN iff r lies properly to the left of, on, or properly to the right of the oriented line through p and q, resp.

See Also

Min_circle_2 , Min_circle_2_traits_2 , Min_circle_2_adapterC2 , Requirements of Traits Class Adapters to 2D Homogeneous Points.

Example

The following example illustrates the use of the traits class adapters with your own point class. For the sake of simplicity, we expect a point class with homogeneous int coordinates and access functions hx(), hy(), and hw(). Based on this we show how to implement and use data accessors.

Note: In this release correct results are only guaranteed if exact arithmetic is used, so this example (using integer arithmetic with possible overflows) is only intended to illustrate the techniques.

#include <CGAL/Min_circle_2_adapterH2.h>
#include <CGAL/Min_circle_2.h>
using namespace CGAL;

// your own point class (homogeneous)
class PtH {
    // ...
  public:
    PtH( int hx, int hy, int hw);
    int  hx( ) const;
    int  hy( ) const;
    int  hw( ) const;
    // ...
};

// the data accessor for PtH
class PtH_DA {
  public:
    typedef  int  RT;
    void  get( const PtH& p, int& hx, int& hy, int& hw) const {
        hx = p.hx(); hy = p.hy(); hw.phw();
    }
    int  get_x( const PtH& p) const { return( p.hx()); }
    int  get_y( const PtH& p) const { return( p.hy()); }
    int  get_w( const PtH& p) const { return( p.hw()); }
    void  set( PtH& p, int hx, int hy, int hw) const { p = PtH( hx, hy, hw); }
};

// some typedefs
typedef  Min_circle_2_adapterH2< PtH, PtH_DA >  AdapterH;
typedef  Min_circle_2< AdapterH >               Min_circle;

// do something with Min_circle
Min_circle   mc( /*...*/ );


Next: Requirements of Traits Class Adapters to 2D Cartesian Points
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The GALIA project. Jan 18, 2000.