DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Static Public Member Functions
DGtal::AngleComputer Struct Reference

#include <AngleComputer.h>

Static Public Member Functions

static float cast (float i)
static bool less (float i, float j)
static float posDiff (float j, float i)
static float deviation (float j, float i)
static float min (float i, float j)
static float max (float i, float j)
static double cast (double i)
static bool less (double i, double j)
static double posDiff (double j, double i)
static double deviation (double j, double i)
static double min (double i, double j)
static double max (double i, double j)

Detailed Description

A simple class to perform angle computations. All angles are in [0:2pi[

Definition at line 69 of file AngleComputer.h.


Member Function Documentation

float DGtal::AngleComputer::cast ( float  i)
inlinestatic
Parameters:
iany angle.
Returns:
the corresponding angle in [0:2pi[

Definition at line 54 of file AngleComputer.ih.

References M_PI.

Referenced by DGtal::AngleLinearMinimizer::oneStep(), DGtal::AngleLinearMinimizerByRelaxation::oneStep(), DGtal::AngleLinearMinimizerByGradientDescent::oneStep(), and DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::oneStep().

{
while ( i < 0.0f ) i += (float) (M_PI*2.0);
while ( i > (double)(M_PI*2.0) ) i -= (float)(M_PI*2.0);
return i;
}
double DGtal::AngleComputer::cast ( double  i)
inlinestatic
Parameters:
iany angle.
Returns:
the corresponding angle in [0:2pi[

Definition at line 147 of file AngleComputer.ih.

References M_PI.

{
while ( i < 0.0 ) i += (float)(M_PI*2.0);
while ( i > (float)(M_PI*2.0) ) i -= (float)(M_PI*2.0);
return i;
}
float DGtal::AngleComputer::deviation ( float  j,
float  i 
)
inlinestatic

Performs j - i, assuming th result is in [-pi:pi[

Parameters:
jany angle in [0:2pi[
iany angle in [0:2pi[
Returns:
the value j - i, always positive.

Definition at line 105 of file AngleComputer.ih.

Referenced by DGtal::AngleLinearMinimizer::getEnergy(), DGtal::AngleLinearMinimizer::getFormerEnergy(), DGtal::AngleLinearMinimizer::getFormerGradient(), DGtal::AngleLinearMinimizer::getGradient(), DGtal::AngleLinearMinimizer::oneStep(), DGtal::AngleLinearMinimizerByRelaxation::oneStep(), and DGtal::AngleLinearMinimizer::optimize().

{
return less( i, j ) ? posDiff( j, i ) : -posDiff( i, j );
}
double DGtal::AngleComputer::deviation ( double  j,
double  i 
)
inlinestatic

Performs j - i, assuming th result is in [-pi:pi[

Parameters:
jany angle in [0:2pi[
iany angle in [0:2pi[
Returns:
the value j - i, always positive.

Definition at line 198 of file AngleComputer.ih.

{
return less( i, j ) ? posDiff( j, i ) : -posDiff( i, j );
}
bool DGtal::AngleComputer::less ( float  i,
float  j 
)
inlinestatic

Less comparator modulo. Be careful, modulo comparisons have no sense when the absolute difference of the values are around pi.

Parameters:
iany angle in [0:2pi[
jany angle in [0:2pi[
Returns:
'true' if [i] strictly precedes [j] in a window 'pi'.

Definition at line 72 of file AngleComputer.ih.

References M_PI.

Referenced by DGtal::AngleLinearMinimizer::oneStep(), DGtal::AngleLinearMinimizerByRelaxation::oneStep(), DGtal::AngleLinearMinimizerByGradientDescent::oneStep(), and DGtal::AngleLinearMinimizerByAdaptiveStepGradientDescent::oneStep().

{
float d = j - i;
if ( d > 0.0f )
return d < M_PI;
else
return (-d) >= M_PI;
}
bool DGtal::AngleComputer::less ( double  i,
double  j 
)
inlinestatic

Less comparator modulo. Be careful, modulo comparisons have no sense when the absolute difference of the values are around pi.

Parameters:
iany angle in [0:2pi[
jany angle in [0:2pi[
Returns:
'true' if [i] strictly precedes [j] in a window 'pi'.

Definition at line 165 of file AngleComputer.ih.

References M_PI.

{
double d = j - i;
if ( d > 0.0 )
return d < M_PI;
else
return (-d) >= M_PI;
}
float DGtal::AngleComputer::max ( float  i,
float  j 
)
inlinestatic

Equivalent to 'less( i, j ) ? j : i'.

Parameters:
iany angle in [0:2pi[
jany angle in [0:2pi[
Returns:
the greatest angle of [i] and [j] in a window 'pi'.

Definition at line 134 of file AngleComputer.ih.

{
return less( i, j ) ? j : i;
}
double DGtal::AngleComputer::max ( double  i,
double  j 
)
inlinestatic

Equivalent to 'less( i, j ) ? j : i'.

Parameters:
iany angle in [0:2pi[
jany angle in [0:2pi[
Returns:
the greatest angle of [i] and [j] in a window 'pi'.

Definition at line 227 of file AngleComputer.ih.

{
return less( i, j ) ? j : i;
}
float DGtal::AngleComputer::min ( float  i,
float  j 
)
inlinestatic

Equivalent to 'less( i, j ) ? i : j'.

Parameters:
iany angle in [0:2pi[
jany angle in [0:2pi[
Returns:
the smallest angle of [i] and [j] in a window 'pi'.

Definition at line 120 of file AngleComputer.ih.

{
return less( i, j ) ? i : j;
}
double DGtal::AngleComputer::min ( double  i,
double  j 
)
inlinestatic

Equivalent to 'less( i, j ) ? i : j'.

Parameters:
iany angle in [0:2pi[
jany angle in [0:2pi[
Returns:
the smallest angle of [i] and [j] in a window 'pi'.

Definition at line 213 of file AngleComputer.ih.

{
return less( i, j ) ? i : j;
}
float DGtal::AngleComputer::posDiff ( float  j,
float  i 
)
inlinestatic

Performs j - i modulo 2pi, assuming less(i,j) is true.

Parameters:
jany angle in [0:2pi[
iany angle in [0:2pi[
Returns:
the value j - i, always positive.

Definition at line 91 of file AngleComputer.ih.

References M_PI.

{
return ( i <= j ) ? j - i : j + (float)(M_PI*2.0) - i;
}
double DGtal::AngleComputer::posDiff ( double  j,
double  i 
)
inlinestatic

Performs j - i modulo 2pi, assuming less(i,j) is true.

Parameters:
jany angle in [0:2pi[
iany angle in [0:2pi[
Returns:
the value j - i, always positive.

Definition at line 184 of file AngleComputer.ih.

References M_PI.

{
return ( i <= j ) ? j - i : j + (float)(M_PI*2.0) - i;
}

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