# PlotMM::DoubleIntMap Class Reference

List of all members.

## Detailed Description

Map a double interval into an integer interval.

The DoubleIntMap class maps an interval of type double into an interval of type int. It consists of two intervals D = [d1, d2] (double) and I = [i1, i2] (int), which are specified with the DoubleIntMap::set_dbl_range and DoubleIntMap::set_int_range members. The point d1 is mapped to the point i1, and d2 is mapped to i2. Any point inside or outside D can be mapped to a point inside or outside I using DoubleIntMap::transform or DoubleIntMap::lim_transform or vice versa using Plot::inv_transform. D can be scaled linearly or logarithmically, as specified with DoubleIntMap::set_dbl_range.

Usage

         *  #include <plotmm/doubleintmap.h>
         *
         *  DoubleIntMap map;
         *  int ival;
         *  double dval;
         *
         *  // Assign an interval of type double with linear mapping
         *  map.set_dbl_range(0.0, 3.1415);
         *
         *  // Assign an integer interval
         *  map.set_int_range(0,100);
         *
         *  // obtain integer value corresponding to 1.0
         *  ival = map.transform(1.0);
         *
         *  // obtain double value corresponding to 77
         *  dval = map.inv_transform(77);
         *

## Public Member Functions

| DoubleIntMap ()
| DoubleIntMap (int i1, int i2, double d1, double d2, bool lg=false)
| ~DoubleIntMap ()
bool | contains (double x) const
bool | contains (int x) const
void | set_int_range (int i1, int i2)
void | set_dbl_range (double d1, double d2, bool lg=false)
int | transform (double x) const
double | inv_transform (int i) const
int | lim_transform (double x) const
double | x_transform (double x) const
double | d1 () const
double | d2 () const
int | i1 () const
int | i2 () const
bool | logarithmic () const

## Static Public Attributes

static const double | LogMin = 1.0e-150
static const double | LogMax = 1.0e150

## Constructor & Destructor Documentation

DoubleIntMap::DoubleIntMap | ( |  | ) |

| Constructor. The double and integer intervals are both set to [0,1].

DoubleIntMap::DoubleIntMap | ( | int | i1,
|  | int | i2,
|  | double | d1,
|  | double | d2,
|  | bool | logarithmic = `false`
| ) |

Constructor.

Constructs a DoubleIntMap instance with initial integer and double intervals

Parameters:

  | i1 | first border of integer interval
  | i2 | second border of integer interval
  | d1 | first border of double interval
  | d2 | second border of double interval
  | logarithmic | logarithmic mapping, true or false.

DoubleIntMap::~DoubleIntMap | ( |  | ) |

| Destructor.

## Member Function Documentation

bool DoubleIntMap::contains | ( | int | x | ) | const

Returns:
  true if a value x lies inside or at the border of the map's integer range

Parameters:

  | x | value

bool DoubleIntMap::contains | ( | double | x | ) | const

Returns:
  true if a value x lies inside or at the border of the map's double range.

Parameters:

  | x | value

double PlotMM::DoubleIntMap::d1 | ( |  | ) | const

Returns:
  the first border of the double interval

double PlotMM::DoubleIntMap::d2 | ( |  | ) | const

Returns:
  the second border of the double interval

int PlotMM::DoubleIntMap::i1 | ( |  | ) | const

Returns:
  the second border of the integer interval

int PlotMM::DoubleIntMap::i2 | ( |  | ) | const

Returns:
  the second border of the integer interval

double DoubleIntMap::inv_transform | ( | int | y | ) | const

Transform an integer value into a double value.

Parameters:

  | y | integer value to be transformed

Returns:
  linear mapping:
    d1 + (d2 - d1) / (i2 - i1) * (y - i1)
  logarithmic mapping:
    d1 + (d2 - d1) / log(i2 / i1) * log(y / i1)

int DoubleIntMap::lim_transform | ( | double | x | ) | const

Transform and limit.

The function is similar to DoubleIntMap::transform, but limits the input value to the nearest border of the map's double interval if it lies outside that interval.

Parameters:

  | x | value to be transformed

Returns:
  transformed value

bool PlotMM::DoubleIntMap::logarithmic | ( |  | ) | const

Returns:
  TRUE if the double interval is scaled logarithmically

void DoubleIntMap::set_dbl_range | ( | double | d1,
|  | double | d2,
|  | bool | lg = `false`
| ) |

Specify the borders of the double interval.

Parameters:

  | d1 | first border
  | d2 | second border
  | lg | logarithmic (true) or linear (false) scaling

void DoubleIntMap::set_int_range | ( | int | i1,
|  | int | i2
| ) |

Specify the borders of the integer interval.

Parameters:

  | i1 | first border
  | i2 | second border

int PlotMM::DoubleIntMap::transform | ( | double | x | ) | const

Transform a point in double interval into an point in the integer interval

Parameters:

  | x | value

Returns:
  linear mapping:
    rint(i1 + (i2 - i1) / (d2 - d1) * (x - d1))
  logarithmic mapping:
    rint(i1 + (i2 - i1) / log(d2 / d1) * log(x / d1))

Warning:
  The specified point is allowed to lie outside the intervals. If you want to limit the returned value, use DoubleIntMap::lim_transform.

double DoubleIntMap::x_transform | ( | double | x | ) | const

Exact transformation.

This function is similar to DoubleIntMap::transform, but makes the integer interval appear to be double.

Parameters:

  | x | value to be transformed

Returns:
  linear mapping:
    i1 + (i2 - i1) / (d2 - d1) * (x - d1)
  logarithmic mapping:
    i1 + (i2 - i1) / log(d2 / d1) * log(x / d1)