This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YASMIN/ui/debug/plot/Range.h
kazu 075d8bb633 a lot!!! of changes
added main menu
added debug display
many debug widgets for plotting live data
worked on android live sensors
added offline-data sensor feeding
some dummy data sensors
worked on the map display
added ui debug for grid-points, particles and weights
added a cool dude to display the estimation
added real filtering based on the Indoor components
c++11 fixes for android compilation
online and offline filtering support
new resampling technique for testing
map loading via dialog
2016-09-16 19:30:04 +02:00

49 lines
810 B
C

#ifndef PLOT_RANGE_H
#define PLOT_RANGE_H
struct Range {
float min;
float max;
Range() : min(0), max(0) {;}
Range(const float min, const float max) : min(min), max(max) {
;
}
float getSize() const {
return max-min;
}
float getCenter() const {
return (max+min)/2;
}
bool isValid() const {
return getSize() > 0;
}
/** resize the region. 1.0 = keep-as-is */
void scale(const float val) {
const float center = getCenter();
const float size = getSize();
min = center - size / 2 * val;
max = center + size / 2 * val;
}
/** adjust (grow) the range */
void adjust(const float val) {
if (val < min) {min = val;}
if (val > max) {max = val;}
}
void adjust(const Range& o) {
if (o.min < min) {min = o.min;}
if (o.max > max) {max = o.max;}
}
};
#endif // PLOT_RANGE_H