DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DGtal::Ellipse2D< TSpace > Class Template Reference

#include <Ellipse2D.h>

Inheritance diagram for DGtal::Ellipse2D< TSpace >:
Inheritance graph
[legend]
Collaboration diagram for DGtal::Ellipse2D< TSpace >:
Collaboration graph
[legend]

Public Types

typedef TSpace Space
typedef Space::Point Point
typedef Space::RealPoint RealPoint2D
typedef Space::RealVector RealVector2D
- Public Types inherited from DGtal::StarShaped2D< TSpace >
typedef Space::RealPoint RealPoint

Public Member Functions

 ~Ellipse2D ()
 Ellipse2D (const double x0, const double y0, const double a0, const double a1, const double theta)
 Ellipse2D (const RealPoint2D &aPoint, const double a0, const double a1, const double theta)
 Ellipse2D (const Point &aPoint, const double a0, const double a1, const double theta)
RealPoint2D getLowerBound () const
RealPoint2D getUpperBound () const
RealPoint2D center () const
double parameter (const RealPoint2D &p) const
RealPoint2D x (const double t) const
RealVector2D xp (const double t) const
RealVector2D xpp (const double t) const
void selfDisplay (std::ostream &out) const
bool isValid () const
- Public Member Functions inherited from DGtal::StarShaped2D< TSpace >
 StarShaped2D ()
 ~StarShaped2D ()
virtual RealPoint interiorPoint () const
bool isInside (const RealPoint &p) const
bool isInside (const Point &p) const
Orientation orientation (const RealPoint &p) const
RealPoint tangent (double t) const
RealPoint normal (double t) const
double curvature (double t) const
double arclength (double t1, double t2, unsigned int nb) const

Protected Member Functions

 Ellipse2D ()

Private Member Functions

Ellipse2Doperator= (const Ellipse2D &other)

Private Attributes

RealPoint2D myCenter
double myAxis1
double myAxis2
double myTheta

Detailed Description

template<typename TSpace>
class DGtal::Ellipse2D< TSpace >

Aim: Model of the concept StarShaped represents any ellipse in the plane.

Description of template class 'Ellipse2D'

NB: A backport from ImaGene.

Definition at line 64 of file Ellipse2D.h.


Member Typedef Documentation

template<typename TSpace>
typedef Space::Point DGtal::Ellipse2D< TSpace >::Point

Reimplemented from DGtal::StarShaped2D< TSpace >.

Definition at line 70 of file Ellipse2D.h.

template<typename TSpace>
typedef Space::RealPoint DGtal::Ellipse2D< TSpace >::RealPoint2D

Definition at line 71 of file Ellipse2D.h.

template<typename TSpace>
typedef Space::RealVector DGtal::Ellipse2D< TSpace >::RealVector2D

Definition at line 72 of file Ellipse2D.h.

template<typename TSpace>
typedef TSpace DGtal::Ellipse2D< TSpace >::Space

Reimplemented from DGtal::StarShaped2D< TSpace >.

Definition at line 69 of file Ellipse2D.h.


Constructor & Destructor Documentation

template<typename T >
DGtal::Ellipse2D< T >::~Ellipse2D ( )
inline

Destructor.

Definition at line 48 of file Ellipse2D.ih.

{
}
template<typename T >
DGtal::Ellipse2D< T >::Ellipse2D ( const double  x0,
const double  y0,
const double  a0,
const double  a1,
const double  theta 
)
inline

Constructor.

Parameters:
x0the x-coordinate of the circle center.
y0the y-coordinate of the circle center.
a1the half big axis of the ellipse.
a2the half small axis of the ellipse.
thetathe orientation of the ellipse.

Definition at line 54 of file Ellipse2D.ih.

: myCenter(x0,y0), myAxis1(a0),myAxis2(a1),myTheta(theta)
{}
template<typename T >
DGtal::Ellipse2D< T >::Ellipse2D ( const RealPoint2D aPoint,
const double  a0,
const double  a1,
const double  theta 
)
inline

Constructor.

Parameters:
aPointthe circle center.
a1the half big axis of the ellipse.
a2the half small axis of the ellipse.
thetathe orientation of the ellipse.

Definition at line 62 of file Ellipse2D.ih.

: myCenter(aPoint), myAxis1(a0),myAxis2(a1),myTheta(theta)
{}
template<typename T >
DGtal::Ellipse2D< T >::Ellipse2D ( const Point aPoint,
const double  a0,
const double  a1,
const double  theta 
)
inline

Constructor.

Parameters:
aPointthe circle center.
a1the half big axis of the ellipse.
a2the half small axis of the ellipse.
thetathe orientation of the ellipse.

Definition at line 69 of file Ellipse2D.ih.

References DGtal::Ellipse2D< TSpace >::myCenter.

: myAxis1(a0),myAxis2(a1),myTheta(theta)
{
myCenter = aPoint;
}
template<typename TSpace>
DGtal::Ellipse2D< TSpace >::Ellipse2D ( )
protected

Constructor. Forbidden by default (protected to avoid g++ warnings).


Member Function Documentation

template<typename TSpace>
RealPoint2D DGtal::Ellipse2D< TSpace >::center ( ) const
inlinevirtual
Returns:
the center of the star-shaped object.

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 135 of file Ellipse2D.h.

References DGtal::Ellipse2D< TSpace >::myCenter.

{
return myCenter;
}
template<typename TSpace>
RealPoint2D DGtal::Ellipse2D< TSpace >::getLowerBound ( ) const
inlinevirtual
Returns:
the lower bound of the shape bounding box.

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 118 of file Ellipse2D.h.

References DGtal::Ellipse2D< TSpace >::myAxis1, and DGtal::Ellipse2D< TSpace >::myCenter.

{
}
template<typename TSpace>
RealPoint2D DGtal::Ellipse2D< TSpace >::getUpperBound ( ) const
inlinevirtual
Returns:
the upper bound of the shape bounding box.

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 127 of file Ellipse2D.h.

References DGtal::Ellipse2D< TSpace >::myAxis1, and DGtal::Ellipse2D< TSpace >::myCenter.

{
}
template<typename T >
bool DGtal::Ellipse2D< T >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns:
'true' if the object is valid, 'false' otherwise.

Reimplemented from DGtal::StarShaped2D< TSpace >.

Definition at line 223 of file Ellipse2D.ih.

{
return true;
}
template<typename TSpace>
Ellipse2D& DGtal::Ellipse2D< TSpace >::operator= ( const Ellipse2D< TSpace > &  other)
private

Copy constructor.

Parameters:
otherthe object to clone. Forbidden by default. Assignment.
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename T >
double DGtal::Ellipse2D< T >::parameter ( const RealPoint2D pp) const
inlinevirtual
Parameters:
pany point in the plane.
Returns:
the angle parameter between 0 and 2*Pi corresponding to this point for the shape.

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 88 of file Ellipse2D.ih.

References M_PI.

{
RealPoint2D v2d( pp );
v2d -= myCenter;
double angle;
if ( v2d[0] == 0.0 )
{
if ( v2d[1] >0 )
angle = M_PI/2.0;
else
angle = 1.5*M_PI;
}
else if ( ( v2d[0] > 0.0 ) && ( v2d[1] >= 0.0 ) )
angle = atan(v2d[1]/v2d[0]);
else if ( ( v2d[0] > 0.0 ) && ( v2d[1] <= 0.0 ) )
angle = 2*M_PI + atan(v2d[1]/v2d[0]);
else if ( ( v2d[0] < 0.0 ) && ( v2d[1] >= 0.0 ) )
angle = atan(v2d[1]/v2d[0]) + M_PI;
else // ( ( v2d[0] < 0.0 ) && ( v2d[1] <= 0.0 ) )
angle = atan(v2d[1]/v2d[0]) + M_PI;
return angle;
}
template<typename T >
void DGtal::Ellipse2D< T >::selfDisplay ( std::ostream &  out) const
inline

Writes/Displays the object on an output stream.

Parameters:
outthe output stream where the object is written.

Reimplemented from DGtal::StarShaped2D< TSpace >.

Definition at line 210 of file Ellipse2D.ih.

{
out << "[Ellipse2D] center= "<<myCenter<<" big axis="<<myAxis1
<<" small axis="<<myAxis2<<" phase="<<myTheta;
}
template<typename T >
DGtal::Ellipse2D< T >::RealPoint2D DGtal::Ellipse2D< T >::x ( const double  t) const
inlinevirtual
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x(t),y(t)) which is the position on the shape boundary.

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 123 of file Ellipse2D.ih.

{
double a2 = myAxis1*myAxis1;
double b2 = myAxis2*myAxis2;
double costth = cos( t - myTheta );
// double sintth = sin( t - myTheta );
double cost = cos( t );
double sint = sin( t );
double rho = myAxis2 / sqrt( 1.0 - ((a2-b2)/a2)*costth*costth);
//myAxis2*myAxis1 / sqrt( a2 - (a2-b2)*costth*costth);
RealPoint2D v( rho*cost,
rho*sint );
v += myCenter;
return v;
}
template<typename T >
DGtal::Ellipse2D< T >::RealVector2D DGtal::Ellipse2D< T >::xp ( const double  t) const
inlinevirtual
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x'(t),y'(t)) which is the tangent to the shape boundary.

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 149 of file Ellipse2D.ih.

{
double a2 = myAxis1*myAxis1;
double b2 = myAxis2*myAxis2;
double costth = cos( t - myTheta );
double sintth = sin( t - myTheta );
double cost = cos( t );
double sint = sin( t );
double rho = myAxis2 / sqrt( 1.0 - ((a2-b2)/a2)*costth*costth);
double a = myAxis1;
double b = myAxis2;
double rhod= a*b*(b2-a2)*sintth*costth
/ std::pow( a2*sintth*sintth + b2*costth*costth, 1.5 );
RealPoint2D v( rhod*cost - rho*sint, rhod*sint + rho*cost );
return v;
}
template<typename T >
DGtal::Ellipse2D< T >::RealVector2D DGtal::Ellipse2D< T >::xpp ( const double  t) const
inlinevirtual
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x''(t),y''(t)).

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 175 of file Ellipse2D.ih.

{
double a2 = myAxis1*myAxis1;
double b2 = myAxis2*myAxis2;
double costth = cos( t - myTheta );
double sintth = sin( t - myTheta );
double cost = cos( t );
double sint = sin( t );
double rho = myAxis2 / sqrt( 1.0 - ((a2-b2)/a2)*costth*costth);
double a = myAxis1;
double b = myAxis2;
double rhod = a*b*(b2-a2)*sintth*costth
/ std::pow( a2*sintth*sintth + b2*costth*costth, 1.5 );
double rhodd = a*b*(b2-a2)
/ std::pow( a2*sintth*sintth + b2*costth*costth, 2.5 )
* ( (costth*costth - sintth*sintth) * (a2*sintth*sintth + b2*costth*costth)
+ 3.0*(b2-a2)*sintth*sintth*costth*costth );
RealPoint2D v( rhodd*cost - 2.0*rhod*sint - rho*cost,
rhodd*sint + 2.0*rhod*cost - rho*sint );
return v;
}

Field Documentation

template<typename TSpace>
double DGtal::Ellipse2D< TSpace >::myAxis1
private
template<typename TSpace>
double DGtal::Ellipse2D< TSpace >::myAxis2
private

Second axis.

Definition at line 190 of file Ellipse2D.h.

template<typename TSpace>
RealPoint2D DGtal::Ellipse2D< TSpace >::myCenter
private
template<typename TSpace>
double DGtal::Ellipse2D< TSpace >::myTheta
private

Orientation (radian).

Definition at line 195 of file Ellipse2D.h.


The documentation for this class was generated from the following files: