Private Member Functions |
| MeasureOfStraightLines (const MeasureOfStraightLines &other) |
MeasureOfStraightLines & | operator= (const MeasureOfStraightLines &other) |
double | computeMeasureEdge (double a0, double b0, double a1, double b1) |
double | computeCentroidEdge_a (double a0, double b0, double a1, double b1) |
double | computeCentroidEdge_b (double a0, double b0, double a1, double b1) |
double | __computeCentroidTriApprox_b (double a0, double b0, double a1, double b1) |
double | __computeCentroidEdgeApprox_b (double a0, double b0, double a1, double b1) |
double | __computeCentroidSquare_b (double x1, double y1, double x2, double y2) |
int | sign (const double a) |
The aim of this class is to compute the measure in the Lebesgues sense of the set of straight lines associated to domains defined as polygons in the (a,b)-parameter space. This parameter space maps the line $ax-y+b=0$ to the point $(a,b)$.
Description of class 'MeasureOfStraightLines'
Aim:
* @inproceedings{COEURJOLLY:2009:HAL-00432711:1,
* title = { {M}easure of {S}traight {L}ines and its {A}pplications in {D}igital {G}eometry},
* author = {{C}oeurjolly, {D}avid and {S}ivignon, {I}sabelle},
* booktitle = {13th {I}nternational {W}orkshop on {C}ombinatorial {I}mage {A}nalysis 13th {I}nternational {W}orkshop on {C}ombinatorial {I}mage {A}nalysis },
* publisher = {{R}esearch {P}ublishing {S}ervices },
* pages = {1-12 },
* address = {{C}ancun {M}exique },
* audience = {internationale },
* year = {2009},
* URL = {http://hal.archives-ouvertes.fr/hal-00432711/PDF/mesure.pdf},
* }
*
- See also:
- testMeasure.cpp
- Todo:
- Create a vector<Point> interface
Definition at line 79 of file MeasureOfStraightLines.h.
double DGtal::MeasureOfStraightLines::__computeCentroidEdgeApprox_b |
( |
double |
a0, |
|
|
double |
b0, |
|
|
double |
a1, |
|
|
double |
b1 |
|
) |
| |
|
inlineprivate |
Approximate the centroid on 'b' on the trapezioid (a0,0)-(a0,b0)-(a1,b1)-(a1,0) (internal function)
- Parameters:
-
a0 | abscissa first point. |
b0 | ordinate of the first point. |
a1 | abscissa of the second point. |
b1 | ordinate of the second point. |
Approximate the centroid on 'b' on the trapezioid (a0,0)-(a0,b0)-(a1,b1)-(a1,0) (internal function)
A0 -> A1
Definition at line 245 of file MeasureOfStraightLines.ih.
{
double measure,y2;
unsigned int nb_step;
if ( a1 < a0 )
{
double tmp = a0;
a0 = a1;
a1 = tmp;
tmp = b0;
b0 = b1;
b1 = tmp;
}
measure = 0;
nb_step = (
unsigned int ) floor ( fabs ( a1-a0 ) /
myEpsilon );
double slope = ( b1-b0 ) / ( a1-a0 );
double decal = b1 - ( b1-b0 ) / ( a1-a0 ) *a1;
if ( slope == 0 )
for ( unsigned int i=0; i < nb_step ; i++ )
{
y2 = ( b1-b0 ) / ( a1-a0 ) * ( a0+ ( i+1 ) *
myEpsilon ) + decal;
if ( y2>0 )
else
}
return measure;
}
double DGtal::MeasureOfStraightLines::__computeCentroidSquare_b |
( |
double |
x1, |
|
|
double |
y1, |
|
|
double |
x2, |
|
|
double |
y2 |
|
) |
| |
|
inlineprivate |
Compute the centroid on 'b' on the rectangular domain with vertices (x1,,y1) - (x2,y2)
- Precondition:
- y1<y2
- Parameters:
-
x1 | abscissa first point. |
y1 | ordinate of the first point. |
x2 | abscissa of the second point. |
y2 | ordinate of the second point. |
Compute the centroid on 'b' on the rectangular domain with vertices (x1,,y1) - (x2,y2) PRECONDITION: y1<y2
Definition at line 218 of file MeasureOfStraightLines.ih.
{
double val;
val = ( ( -1.0* ( sqrt ( 1.0 + pow ( x1,2 ) ) *x2 ) + x1*sqrt ( 1 + pow ( x2,2 ) ) ) * ( pow ( y1,2 ) - pow ( y2,2 ) ) ) / ( 2.0*sqrt ( ( 1.0 + pow ( x1,2 ) ) * ( 1.0 + pow ( x2,2 ) ) ) );
ASSERT ( val>=0 );
return val;
}
double DGtal::MeasureOfStraightLines::__computeCentroidTriApprox_b |
( |
double |
a0, |
|
|
double |
b0, |
|
|
double |
a1, |
|
|
double |
b1 |
|
) |
| |
|
inlineprivate |
Approximate the centroid on 'b' on the triangle (0,0)-(a0,b0)-(a1,b1) (internal function)
- Parameters:
-
a0 | abscissa first point. |
b0 | ordinate of the first point. |
a1 | abscissa of the second point. |
b1 | ordinate of the second point. |
Approximate the centroid on 'b' on the triangle (0,0)-(a0,b0)-(a1,b1) (internal function)
Definition at line 285 of file MeasureOfStraightLines.ih.
{
int signe =
sign ( a0*b1 - a1*b0 );
double measure = 0;
double m_A0A1=0, m_0A0=0, m_0A1=0;
if ( ( b0 != 0 ) && ( a0 != 0 ) )
if ( ( b1 != 0 ) && ( a1 != 0 ) )
if ( ( a1 != a0 ) )
ASSERT ( m_0A0>=0 );
ASSERT ( m_0A1>=0 );
ASSERT ( m_A0A1>=0 );
if ( a0 < a1 )
{
double det = ( a1 * ( b0 - b1 ) - b1* ( a0 - a1 ) );
if ( det >0 )
measure = m_0A0 + m_A0A1 - m_0A1;
else
measure = m_0A1 - m_0A0 - m_A0A1;
}
else
{
double det = ( a0 * ( b1 - b0 ) - b0* ( a1 - a0 ) );
if ( det >0 )
measure = m_0A1 + m_A0A1 - m_0A0;
else
measure = m_0A0 - m_0A1 - m_A0A1;
}
ASSERT ( measure>=0 );
return signe*measure;
}
double DGtal::MeasureOfStraightLines::computeCentroidB |
( |
const std::vector< double > & |
a, |
|
|
const std::vector< double > & |
b |
|
) |
| |
|
inline |
Compute the ordinate of the centroid of the polygon {(a_i,b_i)} in the (a,b)-parameter space with respect to the measure of lines. Note that there is a numerical approximation is performed.
REQUIREMENTS:
- The polygon is given counter-clockwise
- a_i > 0
- Parameters:
-
a | the a-value of polygon vertices |
b | the b-value of polygon vertices |
- Returns:
- the measure value (positive value)
Compute the abscissa of the centroid of the polygon {(a_i,b_i)} in the (a,b)-parameter space
- Parameters:
-
a | the a-value of polygon vertices |
b | the b-value of polygon vertices |
- Returns:
- the measure value (positive value)
Definition at line 191 of file MeasureOfStraightLines.ih.
{
double measure = 0;
double C_b = 0;
ASSERT(a.size() == b.size());
for (unsigned int i=0 ; i < a.size() ; i++)
{
a[ ( i+1 ) % a.size()],b[ ( i+1 ) %a.size()] );
a[ ( i+1 ) % a.size()],b[ ( i+1 ) %a.size()] );
}
return C_b/measure;
}
double DGtal::MeasureOfStraightLines::computeCentroidEdge_a |
( |
double |
a0, |
|
|
double |
b0, |
|
|
double |
a1, |
|
|
double |
b1 |
|
) |
| |
|
inlineprivate |
Compute the abscissa of the centroid associated to an edge (a0,b0)-(a1,b1) It returns the measure of the triangle defined by the origin and the edge.
- Parameters:
-
a0 | abscissa first point. |
b0 | ordinate of the first point. |
a1 | abscissa of the second point. |
b1 | ordinate of the second point. |
- Returns:
- the measure
Compute the centroid on 'a' on the triangle (0,0)-(a0,b0)-(a1,b1)
Definition at line 356 of file MeasureOfStraightLines.ih.
{
double delta= ( a0*b1 - a1*b0 );
if ( ( b0 == 0 ) && ( b1 == 0 ) )
return 0;
if ( ( a0 == 0 ) && ( a1 == 0 ) )
return 0;
if ( a0 == 0 )
return delta* ( a1 - boost::math::asinh ( a1 ) ) / ( a1*a1 );
if ( a1 == 0 )
return delta* ( a0 - boost::math::asinh ( a0 ) ) / ( a0*a0 );
if ( a0 == a1 )
return delta* ( ( -sqrt ( 1 + pow ( a1,-2 ) ) - 1.0/ ( a1*sqrt ( 1 + pow ( a1,2 ) ) ) + a1/sqrt ( 1 + pow ( a1,2 ) ) +
( 2*boost::math::asinh ( a1 ) ) /pow ( a1,2 ) ) /2. );
return delta* ( ( - ( a1*boost::math::asinh ( a0 ) ) + a0*boost::math::asinh ( a1 ) ) / ( a0* ( a0 - a1 ) *a1 ) );
}
double DGtal::MeasureOfStraightLines::computeCentroidEdge_b |
( |
double |
a0, |
|
|
double |
b0, |
|
|
double |
a1, |
|
|
double |
b1 |
|
) |
| |
|
inlineprivate |
Compute the ordinate of the centroid associated to an edge (a0,b0)-(a1,b1) It returns the measure of the triangle defined by the origin and the edge.
- Parameters:
-
a0 | abscissa first point. |
b0 | ordinate of the first point. |
a1 | abscissa of the second point. |
b1 | ordinate of the second point. |
- Returns:
- the measure
Compute the centroid on 'b' on the triangle (0,0)-(a0,b0)-(a1,b1)
Definition at line 327 of file MeasureOfStraightLines.ih.
{
double delta= ( a0*b1 - a1*b0 );
if ( ( b0 == 0 ) && ( b1 == 0 ) )
return 0;
if ( ( a0 == 0 ) && ( a1 == 0 ) )
return 0;
if ( a0 == 0 )
return delta* ( a1* ( ( -2 + sqrt ( 1 + a1*a1 ) ) *b0 + 2*b1 ) + ( b0 - 2*b1 ) *boost::math::asinh ( a1 ) ) / ( 2*a1*a1*a1 );
if ( a1 == 0 )
return delta* ( a0* ( 2*b0 + ( -2 + sqrt ( 1 + a0*a0 ) ) *b1 ) + ( -2*b0 + b1 ) *boost::math::asinh ( a0 ) ) / ( 2*a0*a0*a0 );
if ( a0 == a1 )
return delta* ( ( - ( ( a1* ( b0 + a1* ( -a1 + sqrt ( 1 + pow ( a1,-2 ) ) *sqrt ( 1 + pow ( a1,2 ) ) ) *
b1 ) ) /sqrt ( 1.0 + pow ( a1,2 ) ) ) + ( b0 + b1 ) *boost::math::asinh ( a1 ) ) /
( 2.*pow ( a1,3 ) ) );
}
double DGtal::MeasureOfStraightLines::computeMeasureEdge |
( |
double |
a0, |
|
|
double |
b0, |
|
|
double |
a1, |
|
|
double |
b1 |
|
) |
| |
|
inlineprivate |
Compute the measure associated to an edge (a0,b0)-(a1,b1) It returns the measure of the triangle defined by the origin and the edge.
- Parameters:
-
a0 | abscissa first point. |
b0 | ordinate of the first point. |
a1 | abscissa of the second point. |
b1 | ordinate of the second point. |
- Returns:
- the measure
Compute the measure associated to the Edge (a0,b0) – (a1,b1) in the (a,b)-space
Definition at line 91 of file MeasureOfStraightLines.ih.
{
if ( ( b0 == 0 ) && ( b1 == 0 ) )
return 0;
if ( ( a0 == 0 ) && ( a1 == 0 ) )
return 0;
double delta = ( a0*b1 - a1*b0 );
if ( a0 == 0 )
return delta * ( 1.0/ ( 1.0 + sqrt ( 1 + pow ( a1,2 ) ) ) );
if ( a1 == 0 )
return delta * ( ( -1.0 + sqrt ( 1.0 + pow ( a0,2 ) ) ) /pow ( a0,2 ) );
if ( a0 != a1 )
{
return delta * ( ( a0 - a1 + sqrt ( 1 + pow ( a0,2 ) ) *a1 - a0*sqrt ( 1 + pow ( a1,2 ) ) ) / ( pow ( a0,2 ) *a1 - a0*pow ( a1,2 ) ) );
}
else
return delta * a1/ ( a0* ( 1 + pow ( a1,2 ) + sqrt ( 1 + pow ( a1,2 ) ) ) );
}