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

#include <StarShaped2D.h>

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

Public Types

typedef TSpace Space
typedef Space::Point Point
typedef Space::RealPoint RealPoint

Public Member Functions

 StarShaped2D ()
 ~StarShaped2D ()
virtual RealPoint interiorPoint () const
virtual RealPoint getLowerBound () const =0
virtual RealPoint getUpperBound () const =0
virtual RealPoint center () const =0
virtual double parameter (const RealPoint &p) const =0
virtual RealPoint x (const double t) const =0
virtual RealPoint xp (const double t) const =0
virtual RealPoint xpp (const double t) const =0
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
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

StarShaped2Doperator= (const StarShaped2D &other)

Detailed Description

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

Description of template class 'StarShaped2D'

Aim: Abstract class that represents any star-shaped object in dimension 2. Such a shape as a center and any segment from this center to the shape boundary is included in the shape. These shapes can thus be parameterized by an angle 't' turning around the center.

StarShaped2D and its derived classes are models of CEuclideanBoundedShape and CEuclideanOrientedShape.

NB: A backport from ImaGene.

Template Parameters:
TSpacespace in which the shape is defined.

Definition at line 73 of file StarShaped2D.h.


Member Typedef Documentation

template<typename TSpace>
typedef Space::Point DGtal::StarShaped2D< TSpace >::Point
template<typename TSpace>
typedef Space::RealPoint DGtal::StarShaped2D< TSpace >::RealPoint

Definition at line 79 of file StarShaped2D.h.

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

Constructor & Destructor Documentation

template<typename TSpace>
DGtal::StarShaped2D< TSpace >::StarShaped2D ( )
inline

Constructor.

Definition at line 84 of file StarShaped2D.h.

{}
template<typename T >
DGtal::StarShaped2D< T >::~StarShaped2D ( )
inline

Destructor.

Definition at line 204 of file StarShaped2D.ih.

{
}

Member Function Documentation

template<typename TSpace >
double DGtal::StarShaped2D< TSpace >::arclength ( double  t1,
double  t2,
unsigned int  nb 
) const
inline
Parameters:
t1any angle between 0 and 2*Pi.
t2any angle between 0 and 2*Pi, further from [t1].
nbthe number of points used to estimate the arclength between x(t1) and x(t2).
Returns:
the estimated arclength.

Definition at line 179 of file StarShaped2D.ih.

References M_PI.

{
while ( t2 < t1 ) t2 += 2.0*M_PI;
RealPoint x0( x( t1 ) );
double l = 0.0;
// JOL 2008/08/28
for ( unsigned int i = 1; i <= nb; ++i )
{
double t = ( ( t2 - t1 ) * i ) / nb;
RealPoint x1( x( t1 + t ) );
l += sqrt( ( x1[0] - x0[0] )*( x1[0] - x0[0] )
+ ( x1[1] - x0[1] )*( x1[1] - x0[1] ) );
x0 = x1;
}
return l;
}
template<typename TSpace>
virtual RealPoint DGtal::StarShaped2D< TSpace >::center ( ) const
pure virtual
template<typename TSpace >
double DGtal::StarShaped2D< TSpace >::curvature ( double  t) const
inline
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the algebraic curvature at point (x(t),y(t)), positive is convex, negative is concave when shape is to the left and the shape boundary is followed counterclockwise.

Definition at line 160 of file StarShaped2D.ih.

{
RealPoint tgt( xp( t ) );
RealPoint dt( xpp( t ) );
double norm = tgt.norm();
double curv = ( dt[0] * tgt[1] - dt[1] * tgt[0] ) / ( norm * norm * norm );
return - curv;
}
template<typename TSpace>
virtual RealPoint DGtal::StarShaped2D< TSpace >::getLowerBound ( ) const
pure virtual
template<typename TSpace>
virtual RealPoint DGtal::StarShaped2D< TSpace >::getUpperBound ( ) const
pure virtual
template<typename TSpace>
virtual RealPoint DGtal::StarShaped2D< TSpace >::interiorPoint ( ) const
inlinevirtual
Returns:
a point p such that 'isInside(p)' returns 'true'.

Definition at line 97 of file StarShaped2D.h.

References DGtal::StarShaped2D< TSpace >::center().

{
return center();
}
template<typename TSpace >
bool DGtal::StarShaped2D< TSpace >::isInside ( const RealPoint p) const
inline
Parameters:
pany point in the plane.
Returns:
'true' if the point is inside the shape, 'false' if it is strictly outside.
Parameters:
pany point in the plane.
Returns:
'true' if the point is inside or on the shape, 'false' if it is strictly outside.

Definition at line 74 of file StarShaped2D.ih.

{
double t = parameter( p );
RealPoint x_rel = x( t );
x_rel -= center();
double d_x = x_rel[0]*x_rel[0] + x_rel[1]*x_rel[1];
RealPoint p_rel( p );
p_rel -= center();
double d_p = p_rel[0]*p_rel[0] + p_rel[1]*p_rel[1];
return d_p <= d_x;
}
template<typename TSpace >
bool DGtal::StarShaped2D< TSpace >::isInside ( const Point p) const
inline
Parameters:
pany point in the digital plane.
Returns:
'true' if the point is inside the shape, 'false' if it is strictly outside.
Parameters:
pany point in the plane.
Returns:
'true' if the point is inside the shape, 'false' if it is strictly outside.

Definition at line 55 of file StarShaped2D.ih.

{
RealPoint prel(NumberTraits<typename Point::Component>::castToDouble(p[0]),
NumberTraits<typename Point::Component>::castToDouble(p[1]));
return this->isInside(prel);
}
template<typename T >
bool DGtal::StarShaped2D< T >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Reimplemented in DGtal::AccFlower2D< TSpace >, DGtal::Flower2D< TSpace >, DGtal::Ellipse2D< TSpace >, DGtal::NGon2D< TSpace >, and DGtal::Ball2D< TSpace >.

Definition at line 230 of file StarShaped2D.ih.

{
return true;
}
template<typename TSpace >
DGtal::StarShaped2D< TSpace >::RealPoint DGtal::StarShaped2D< TSpace >::normal ( double  t) const
inline
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x''(t),y''(t)) made unitary which is the unit normal to the shape boundary looking inside the shape.
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x''(t),y''(t)) made unitary which is the unit normal to the shape boundary looking inside the shape. b

Definition at line 143 of file StarShaped2D.ih.

{
RealPoint tgt( tangent( t ) );
return RealPoint( -tgt[1], tgt[0]);
}
template<typename TSpace>
StarShaped2D& DGtal::StarShaped2D< TSpace >::operator= ( const StarShaped2D< TSpace > &  other)
private

Constructor. Forbidden by default (protected to avoid g++ warnings). 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 TSpace >
DGtal::Orientation DGtal::StarShaped2D< TSpace >::orientation ( const RealPoint p) const
inline

Return the orienatation of a point with respect to a shape.

Parameters:
pinput point
Returns:
the orientation of the point (<0 means inside, ...)
Parameters:
pany point in the plane.
Returns:
'true' if the point is inside the shape, 'false' if it is strictly outside.

Definition at line 96 of file StarShaped2D.ih.

References DGtal::INSIDE, DGtal::ON, and DGtal::OUTSIDE.

{
double t = parameter( p );
RealPoint x_rel = x( t );
x_rel -= center();
double d_x = x_rel[0]*x_rel[0] + x_rel[1]*x_rel[1];
RealPoint p_rel( p );
p_rel -= center();
double d_p = p_rel[0]*p_rel[0] + p_rel[1]*p_rel[1];
if (d_p - d_x > 0.0)
return OUTSIDE;
else
if (d_p - d_x < 0.0)
return INSIDE;
else
return ON;
}
template<typename TSpace>
virtual double DGtal::StarShaped2D< TSpace >::parameter ( const RealPoint p) const
pure virtual
Parameters:
pany point in the plane.
Returns:
the angle parameter between 0 and 2*Pi corresponding to this point for the shape.

Implemented in DGtal::AccFlower2D< TSpace >, DGtal::Flower2D< TSpace >, DGtal::Ellipse2D< TSpace >, DGtal::NGon2D< TSpace >, and DGtal::Ball2D< TSpace >.

template<typename T >
void DGtal::StarShaped2D< 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 in DGtal::AccFlower2D< TSpace >, DGtal::Flower2D< TSpace >, DGtal::Ellipse2D< TSpace >, DGtal::NGon2D< TSpace >, and DGtal::Ball2D< TSpace >.

Definition at line 218 of file StarShaped2D.ih.

{
out << "[StarShaped2D]";
}
template<typename TSpace >
DGtal::StarShaped2D< TSpace >::RealPoint DGtal::StarShaped2D< TSpace >::tangent ( double  t) const
inline
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x'(t),y'(t)) made unitary which is the unit tangent to the shape boundary.

Definition at line 125 of file StarShaped2D.ih.

{
RealPoint tgt( xp( t ) );
double norm = tgt.norm();
tgt /= norm;
return tgt;
}
template<typename TSpace>
virtual RealPoint DGtal::StarShaped2D< TSpace >::x ( const double  t) const
pure virtual
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x(t),y(t)) which is the position on the shape boundary.

Implemented in DGtal::AccFlower2D< TSpace >, DGtal::Flower2D< TSpace >, DGtal::Ellipse2D< TSpace >, DGtal::NGon2D< TSpace >, and DGtal::Ball2D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped2D< TSpace >::xp ( const double  t) const
pure virtual
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x'(t),y'(t)) which is the tangent to the shape boundary.

Implemented in DGtal::AccFlower2D< TSpace >, DGtal::Flower2D< TSpace >, DGtal::Ellipse2D< TSpace >, DGtal::NGon2D< TSpace >, and DGtal::Ball2D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped2D< TSpace >::xpp ( const double  t) const
pure virtual
Parameters:
tany angle between 0 and 2*Pi.
Returns:
the vector (x''(t),y''(t)).

Implemented in DGtal::AccFlower2D< TSpace >, DGtal::Flower2D< TSpace >, DGtal::Ellipse2D< TSpace >, DGtal::NGon2D< TSpace >, and DGtal::Ball2D< TSpace >.


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