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

#include <StarShaped3D.h>

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

Public Types

typedef TSpace Space
typedef Space::RealPoint RealPoint
typedef pair< double, double > AngularCoordinates

Public Member Functions

 StarShaped3D ()
 ~StarShaped3D ()
virtual RealPoint interiorPoint () const
virtual RealPoint getLowerBound () const =0
virtual RealPoint getUpperBound () const =0
virtual RealPoint center () const =0
virtual AngularCoordinates parameter (const RealPoint &p) const =0
virtual RealPoint x (const AngularCoordinates t) const =0
virtual RealPoint gradient (const AngularCoordinates t) const =0
virtual RealPoint rt (const AngularCoordinates t) const =0
virtual RealPoint rp (const AngularCoordinates t) const =0
virtual RealPoint rtt (const AngularCoordinates t) const =0
virtual RealPoint rpp (const AngularCoordinates t) const =0
virtual RealPoint rtp (const AngularCoordinates t) const =0
virtual bool isInside (const RealPoint &p) const
virtual Orientation orientation (const RealPoint &p) const
virtual RealPoint normal (AngularCoordinates t) const
virtual double gaussianCurvature (AngularCoordinates t) const
virtual double meanCurvature (AngularCoordinates t) const
virtual double arclength (AngularCoordinates t1, AngularCoordinates t2, unsigned int nb) const
virtual double surfacelength (AngularCoordinates t1, AngularCoordinates t2, unsigned int nb) const
void selfDisplay (std::ostream &out) const
bool isValid () const

Private Member Functions

StarShaped3Doperator= (const StarShaped3D &other)

Detailed Description

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

Description of template class 'StarShaped3D'

Aim: Abstract class that represents any star-shaped object in dimension 3. 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 a couple of angles 'Teta,Phi' turning around the center.

StarShaped3D 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 71 of file StarShaped3D.h.


Member Typedef Documentation

template<typename TSpace>
typedef pair<double,double> DGtal::StarShaped3D< TSpace >::AngularCoordinates

Reimplemented in DGtal::Ball3D< TSpace >.

Definition at line 77 of file StarShaped3D.h.

template<typename TSpace>
typedef Space::RealPoint DGtal::StarShaped3D< TSpace >::RealPoint

Reimplemented in DGtal::Ball3D< TSpace >.

Definition at line 76 of file StarShaped3D.h.

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

Reimplemented in DGtal::Ball3D< TSpace >.

Definition at line 75 of file StarShaped3D.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 82 of file StarShaped3D.h.

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

Destructor.

Definition at line 291 of file StarShaped3D.ih.

{
}

Member Function Documentation

template<typename TSpace >
double DGtal::StarShaped3D< TSpace >::arclength ( AngularCoordinates  t1,
AngularCoordinates  t2,
unsigned int  nb 
) const
inlinevirtual
Parameters:
t1is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
t2is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi]. further from [t1].
nbthe number of points used to estimate the arclength between x(Teta1,Phi1) and x(Teta2,Phi2).
Returns:
the estimated arclength.
Parameters:
t1is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi] .
t2is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi] further from [t1].
nbthe number of points used to estimate the arclength between x(Teta1,Phi1) and x(Teta2,Phi2).
Returns:
the estimated arclength.

Definition at line 218 of file StarShaped3D.ih.

References M_PI.

{
while ( t2.first < t1.first ) t2.first += 2.0*M_PI;
while ( t2.second < t1.second ) t2.second += 2.0*M_PI;
RealPoint x0( x( t1 ) );
double l = 0.0;
for ( unsigned int i = 1; i <= nb; ++i )
{
AngularCoordinates t;
t.first = ( ( t2.first - t1.first ) * i ) / nb;
t.second = ( ( t2.second - t1.second ) * i ) / nb;
AngularCoordinates h;
h.first=t1.first + t.first;
h.second=t1.second + t.second;
RealPoint x1( x( h ) );
l += sqrt( ( x1[0] - x0[0] )*( x1[0] - x0[0] )
+ ( x1[1] - x0[1] )*( x1[1] - x0[1] ) + ( x1[2] - x0[2] )*( x1[2] - x0[2] ) );
x0 = x1;
}
return l;
}
template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::center ( ) const
pure virtual
Returns:
the center of the star-shaped object.

Implemented in DGtal::Ball3D< TSpace >.

Referenced by DGtal::StarShaped3D< TSpace >::interiorPoint().

template<typename TSpace >
double DGtal::StarShaped3D< TSpace >::gaussianCurvature ( AngularCoordinates  t) const
inlinevirtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the gaussian 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.
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi] .
Returns:
the gaussian curvature at point (x(t),y(t),z(t)), positive is convex, negative is concave when shape is to the left and the shape boundary is followed counterclockwise.

Definition at line 178 of file StarShaped3D.ih.

{
typedef typename Space::RealPoint RealPoint;
RealPoint art = rt(t);
RealPoint arp = rp(t);
RealPoint artt = rtt(t);
RealPoint arpp = rpp(t);
RealPoint artp = rtp(t);
RealPoint n(art[1]*arp[2]-art[2]*arp[1],art[2]*arp[0]-art[0]*arp[2],art[0]*arp[1]-art[1]*arp[0]);
double norme= sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);
n[0]=n[0]/norme;
n[1]=n[1]/norme;
n[2]=n[2]/norme;
double E = art[0] * art[0]+ art[1] * art[1]+ art[2] * art[2];
double F= art[0] * arp[0]+ art[1] * arp[1]+ art[2] * arp[2];
double G = arp[0] * arp[0]+ arp[1] * arp[1]+ arp[2] * arp[2];
double L = artt[0] * n[0]+ artt[1] * n[1]+ artt[2] * n[2];
double M = artp[0] * n[0]+ artp[1] * n[1]+ artp[2] * n[2];
double N = arpp[0] * n[0]+ arpp[1] * n[1]+ arpp[2] * n[2];
double K = (L*N-M*M)/(E*G-F*F);
return K;
}
template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::getLowerBound ( ) const
pure virtual
Returns:
the lower bound of the shape bounding box.

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::getUpperBound ( ) const
pure virtual
Returns:
the upper bound of the shape bounding box.

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::gradient ( const AngularCoordinates  t) const
pure virtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (gradf(M).

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::interiorPoint ( ) const
inlinevirtual
Returns:
a point p such that 'isInside(p)' returns 'true'.

Definition at line 95 of file StarShaped3D.h.

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

{
return center();
}
template<typename TSpace >
bool DGtal::StarShaped3D< TSpace >::isInside ( const RealPoint p) const
inlinevirtual
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 58 of file StarShaped3D.ih.

{
AngularCoordinates 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] + x_rel[2]*x_rel[2];
RealPoint p_rel( p );
p_rel -= center();
double d_p = p_rel[0]*p_rel[0] + p_rel[1]*p_rel[1]+ p_rel[2]*p_rel[2];
return d_p <= d_x;
}
template<typename T >
bool DGtal::StarShaped3D< T >::isValid ( ) const
inline

Checks the validity/consistency of the object.

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

Reimplemented in DGtal::Ball3D< TSpace >.

Definition at line 317 of file StarShaped3D.ih.

{
return true;
}
template<typename TSpace >
double DGtal::StarShaped3D< TSpace >::meanCurvature ( AngularCoordinates  t) const
inlinevirtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi]
Returns:
the mean 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.
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi]
Returns:
the mean curvature at point (x(t),y(t),z(t)), positive is convex, negative is concave when shape is to the left and the shape boundary is followed counterclockwise.

Definition at line 137 of file StarShaped3D.ih.

{
typedef typename Space::RealPoint RealPoint;
RealPoint art = rt(t);
RealPoint arp = rp(t);
RealPoint artt = rtt(t);
RealPoint arpp = rpp(t);
RealPoint artp = rtp(t);
RealPoint n(art[1]*arp[2]-art[2]*arp[1],art[2]*arp[0]-art[0]*arp[2],art[0]*arp[1]-art[1]*arp[0]);
double norme= sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);
n[0]=n[0]/norme;
n[1]=n[1]/norme;
n[2]=n[2]/norme;
double E = art[0] * art[0]+ art[1] * art[1]+ art[2] * art[2];
double F= art[0] * arp[0]+ art[1] * arp[1]+ art[2] * arp[2];
double G = arp[0] * arp[0]+ arp[1] * arp[1]+ arp[2] * arp[2];
double L = artt[0] * n[0]+ artt[1] * n[1]+ artt[2] * n[2];
double M = artp[0] * n[0]+ artp[1] * n[1]+ artp[2] * n[2];
double N = arpp[0] * n[0]+ arpp[1] * n[1]+ arpp[2] * n[2];
double H = (E*N-2.0f*F*M+G*L)/(2.0f*(E*G-F*F));
return H;
}
template<typename TSpace >
DGtal::StarShaped3D< TSpace >::RealPoint DGtal::StarShaped3D< TSpace >::normal ( AngularCoordinates  t) const
inlinevirtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (x'(t),y'(t),z'(t)) made unitary which is the unit tangent to the shape boundary.
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector normal made unitary which is the unit normal to the shape boundary looking inside the shape.
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi] a.
Returns:
the vector (gradient(f(x,y,z))) made unitary which is the unit normal to the shape boundary looking inside the shape.

Definition at line 119 of file StarShaped3D.ih.

{
RealPoint aNormal( gradient(t));
double norm = sqrt(aNormal[0]*aNormal[0] + aNormal[1]*aNormal[1] +aNormal[2]*aNormal[2]);
return (RealPoint(aNormal[0]/norm,aNormal[1]/norm,aNormal[2]/norm));
}
template<typename TSpace>
StarShaped3D& DGtal::StarShaped3D< TSpace >::operator= ( const StarShaped3D< TSpace > &  other)
private

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

Parameters:
otherthe object to copy.
Returns:
a reference on 'this'. Forbidden by default.
template<typename TSpace >
DGtal::Orientation DGtal::StarShaped3D< TSpace >::orientation ( const RealPoint p) const
inlinevirtual

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 87 of file StarShaped3D.ih.

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

{
AngularCoordinates 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] + x_rel[2]*x_rel[2];
RealPoint p_rel( p );
p_rel -= center();
double d_p = p_rel[0]*p_rel[0] + p_rel[1]*p_rel[1] + p_rel[2]*p_rel[2];
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 AngularCoordinates DGtal::StarShaped3D< TSpace >::parameter ( const RealPoint p) const
pure virtual
Parameters:
pany point in the sapce.
Returns:
the angles parameters (Teta, Phi) corresponding to this point for the shape.

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::rp ( const AngularCoordinates  t) const
pure virtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (rp(M)) wich is the first partial derivative with respect to Phi.

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::rpp ( const AngularCoordinates  t) const
pure virtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (rpp(M)) wich is second the partial derivative with respect to Phi.

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::rt ( const AngularCoordinates  t) const
pure virtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (rt(M)) wich is the partial derivative with respect to Teta.

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::rtp ( const AngularCoordinates  t) const
pure virtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (rpp(M)) wich is second the partial derivative with respect to Teta then Phi.

Implemented in DGtal::Ball3D< TSpace >.

template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::rtt ( const AngularCoordinates  t) const
pure virtual
Parameters:
tis a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (rtt(M)) wich is second the partial derivative with respect to Teta(twice).

Implemented in DGtal::Ball3D< TSpace >.

template<typename T >
void DGtal::StarShaped3D< 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::Ball3D< TSpace >.

Definition at line 305 of file StarShaped3D.ih.

{
out << "[StarShaped2D]";
}
template<typename TSpace >
double DGtal::StarShaped3D< TSpace >::surfacelength ( AngularCoordinates  t1,
AngularCoordinates  t2,
unsigned int  nb 
) const
inlinevirtual
Parameters:
t1is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
t2is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi]. further from [t1].
nbthe number of points used to estimate the surface between x(Teta1,Phi1) and x(Teta2,Phi2).
Returns:
the estimated surfacelength.
Parameters:
t1is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
t2is a couple of Teta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi], further from [t1].
nbthe number of points used to estimate the surfacelength between x(Teta1,Phi1) and x(Teta2,Phi2).
Returns:
the estimated surfacelength.

Definition at line 251 of file StarShaped3D.ih.

References M_PI.

{
while ( t2.first < t1.first ) t2.first += 2.0*M_PI;
while ( t2.second < t1.second ) t2.second += 2.0*M_PI;
double step1 = ( t2.first - t1.first ) / nb;
double step2 = ( t2.second - t1.second ) / nb;
AngularCoordinates t( make_pair(0.0,0.0));
double l = 0.0;
for ( unsigned int i = 0; i < nb; ++i )
{
t.first = step1 *i;
for ( unsigned int j = 0; j < nb; ++j )
{
t.second = step2 * j;
RealPoint xtp (x( make_pair( t1.first + t.first - step1 ,t1.second + t.second - step2 ) ));
RealPoint xt1p1( x( make_pair(t1.first + t.first,t1.second + t.second) ) );
RealPoint xt1p( x( make_pair(t1.first + t.first,t1.second + t.second- step2 ) ) );
double D = sqrt( ( xt1p[0] - xtp[0] )*( xt1p[0] - xtp[0] ) +
( xt1p[1] - xtp[1] )*( xt1p[1] - xtp[1] ) +
( xt1p[2] - xtp[2] )*( xt1p[2] - xtp[2] ));
double d = sqrt( ( xt1p1[0] - xt1p[0] )*( xt1p1[0] - xt1p[0] ) +
( xt1p1[1] - xt1p[1] )*( xt1p1[1] - xt1p[1] ) +
( xt1p1[2] - xt1p[2] )*( xt1p1[2] - xt1p[2] ));
l += (d*D);
}
}
return l;
}
template<typename TSpace>
virtual RealPoint DGtal::StarShaped3D< TSpace >::x ( const AngularCoordinates  t) const
pure virtual
Parameters:
tis a couple of Theta && Phi wich are 2 angles respectivly between [0,2PI] and [0,Pi].
Returns:
the vector (x(t),y(t),z(t)) which is the position on the shape boundary.

Implemented in DGtal::Ball3D< TSpace >.


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