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

Traits Class Adapter for 2D Smallest Enclosing Ellipse to 2D Cartesian Points (Min_ellipse_2_adapterC2)

Definition

The class Min_ellipse_2_adapterC2<PT,DA> interfaces the 2D optimisation algorithm for smallest enclosing ellipses with the point class PT. The data accessor DA [KW97] is used to access the x- and y-coordinate of PT, i.e. PT is supposed to have a Cartesian representation of its coordinates.

#include <CGAL/Min_ellipse_2_adapterC2.h>

Types

Min_ellipse_2_adapterC2<PT,DA>::DA
Data accessor for Cartesian coordinates.


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


Min_ellipse_2_adapterC2<PT,DA>::Ellipse
Ellipse type.

Creation

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

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

See Also

Min_ellipse_2 , Min_ellipse_2_traits_2 , Min_ellipse_2_adapterH2 , Requirements of Traits Class Adapters to 2D Cartesian 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 Cartesian double coordinates and access functions x() and y(). 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 inexact floating-point arithmetic) is only intended to illustrate the techniques.

#include <CGAL/Min_ellipse_2_adapterC2.h>
#include <CGAL/Min_ellipse_2.h>
using namespace CGAL;

// your own point class (Cartesian)
class PtC {
    // ...
  public:
    PtC( double x, double y);
    double  x( ) const;
    double  y( ) const;
    // ...
};

// the data accessor for PtC
class PtC_DA {
  public:
    typedef  double  FT;
    void  get( const PtC& p, double& x, double& y) const {
        x = p.x(); y = p.y();
    }
    double  get_x( const PtC& p) const { return( p.x()); }
    double  get_y( const PtC& p) const { return( p.y()); }
    void  set( PtC& p, double x, double y) const { p = PtC( x, y); }
};

// some typedefs
typedef  Min_ellipse_2_adapterC2 < PtC, PtC_DA >  AdapterC;
typedef  Min_ellipse_2 < AdapterC >               Min_ellipse;

// do something with Min_ellipse
Min_ellipse   me( /*...*/ );


Next: Class declaration of Min_ellipse_2_adapterH2<PT,DA>
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The GALIA project. Jan 18, 2000.