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::Ball2D< TSpace > Class Template Reference

#include <Ball2D.h>

Inheritance diagram for DGtal::Ball2D< TSpace >:
Inheritance graph
[legend]
Collaboration diagram for DGtal::Ball2D< 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

 ~Ball2D ()
 Ball2D (const double x0, const double y0, const double r)
 Ball2D (const RealPoint2D &aPoint, const double r)
 Ball2D (const Point &aPoint, const double r)
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

 Ball2D ()

Private Member Functions

Ball2Doperator= (const Ball2D &other)

Private Attributes

double myRadius
RealPoint2D myCenter

Detailed Description

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

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

Description of template class 'Ball2D'

Definition at line 60 of file Ball2D.h.


Member Typedef Documentation

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

Reimplemented from DGtal::StarShaped2D< TSpace >.

Definition at line 66 of file Ball2D.h.

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

Definition at line 67 of file Ball2D.h.

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

Definition at line 68 of file Ball2D.h.

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

Reimplemented from DGtal::StarShaped2D< TSpace >.

Definition at line 65 of file Ball2D.h.


Constructor & Destructor Documentation

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

Destructor.

Definition at line 46 of file Ball2D.ih.

{
}
template<typename T >
DGtal::Ball2D< T >::Ball2D ( const double  x0,
const double  y0,
const double  r 
)
inline

Constructor.

Parameters:
x0the x-coordinate of the circle center.
y0the y-coordinate of the circle center.
rthe radius of the circle.

Definition at line 52 of file Ball2D.ih.

:
myRadius(radius), myCenter(x0,y0)
{}
template<typename T >
DGtal::Ball2D< T >::Ball2D ( const RealPoint2D aPoint,
const double  r 
)
inline

Constructor.

Parameters:
aPointthe circle center.
rthe radius of the circle.

Definition at line 59 of file Ball2D.ih.

:
myRadius(radius), myCenter(aPoint)
{}
template<typename T >
DGtal::Ball2D< T >::Ball2D ( const Point aPoint,
const double  r 
)
inline

Constructor.

Parameters:
aPointthe circle center.
rthe radius of the circle.

Definition at line 65 of file Ball2D.ih.

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

:
myRadius(radius)
{
myCenter = aPoint;
}
template<typename TSpace>
DGtal::Ball2D< TSpace >::Ball2D ( )
protected

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


Member Function Documentation

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

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 122 of file Ball2D.h.

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

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

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 105 of file Ball2D.h.

References DGtal::Ball2D< TSpace >::myCenter, and DGtal::Ball2D< TSpace >::myRadius.

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

Implements DGtal::StarShaped2D< TSpace >.

Definition at line 114 of file Ball2D.h.

References DGtal::Ball2D< TSpace >::myCenter, and DGtal::Ball2D< TSpace >::myRadius.

{
}
template<typename T >
bool DGtal::Ball2D< 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 178 of file Ball2D.ih.

{
return true;
}
template<typename TSpace>
Ball2D& DGtal::Ball2D< TSpace >::operator= ( const Ball2D< 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::Ball2D< 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 83 of file Ball2D.ih.

References M_PI.

{
RealPoint2D p( pp );
p -= myCenter;
double angle = 0.0;
if ( ( p.at( 0 ) == 0.0 ) && ( p.at( 1 ) == 0.0 ) )
return angle;
if ( p.at( 0 ) >= p.at( 1 ) )
{
if ( p.at( 0 ) >= -p.at( 1 ) )
angle = atan( p.at( 1 ) / p.at( 0 ) );
else
angle = 1.5* M_PI + atan( - p.at( 0 ) / p.at( 1 ) );
}
else // ( p.at( 0 ) >= p.at( 1 ) )
{
if ( p.at( 0 ) >= -p.at( 1 ) )
angle = 0.5*M_PI - atan( p.at( 0 ) / p.at( 1 ) );
else
angle = M_PI + atan( p.at( 1 ) / p.at( 0 ) );
}
angle = ( angle < 0.0 ) ? angle + 2*M_PI : angle;
return angle;
}
template<typename T >
void DGtal::Ball2D< 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 166 of file Ball2D.ih.

{
out << "[Ball2D] center= "<<myCenter<<" radius="<<myRadius;
}
template<typename T >
DGtal::Ball2D< T >::RealPoint2D DGtal::Ball2D< 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 118 of file Ball2D.ih.

{
RealPoint2D c( myRadius*cos(t), myRadius*sin(t) );
c += myCenter;
return c;
}
template<typename T >
DGtal::Ball2D< T >::RealVector2D DGtal::Ball2D< 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 135 of file Ball2D.ih.

{
RealVector2D c( -myRadius*sin(t), myRadius*cos(t) );
return c;
}
template<typename T >
DGtal::Ball2D< T >::RealVector2D DGtal::Ball2D< 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 149 of file Ball2D.ih.

{
RealVector2D c( -myRadius*cos(t), -myRadius*sin(t) );
return c;
}

Field Documentation

template<typename TSpace>
RealPoint2D DGtal::Ball2D< TSpace >::myCenter
private

Center of the circle.

Definition at line 171 of file Ball2D.h.

Referenced by DGtal::Ball2D< TSpace >::Ball2D(), DGtal::Ball2D< TSpace >::center(), DGtal::Ball2D< TSpace >::getLowerBound(), and DGtal::Ball2D< TSpace >::getUpperBound().

template<typename TSpace>
double DGtal::Ball2D< TSpace >::myRadius
private

Radius of the circle.

Definition at line 166 of file Ball2D.h.

Referenced by DGtal::Ball2D< TSpace >::getLowerBound(), and DGtal::Ball2D< TSpace >::getUpperBound().


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