X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FDoubleRange.java;h=4e361224f420ed32b72473edc1e5adf87d37a3f0;hb=7f5ed2be62905bd37717376dc22d09e5ea7edb4d;hp=b7d4771b5ce28c8d6a54fdffd077224a77cf16c1;hpb=312fec956e43f5d0a38617da5d0add9c62563e2c;p=GpsPrune.git diff --git a/tim/prune/data/DoubleRange.java b/tim/prune/data/DoubleRange.java index b7d4771..4e36122 100644 --- a/tim/prune/data/DoubleRange.java +++ b/tim/prune/data/DoubleRange.java @@ -10,6 +10,30 @@ public class DoubleRange private double _min = 0.0, _max = 0.0; + /** Empty constructor, cleared to zeroes */ + public DoubleRange() {} + + /** + * Constructor giving two initial values + * @param inValue1 first value + * @param inValue2 second value + */ + public DoubleRange(double inValue1, double inValue2) + { + addValue(inValue1); + addValue(inValue2); + } + + /** + * Clear for a new calculation + */ + public void clear() + { + _min = _max = 0.0; + _empty = true; + } + + /** * Add a value to the range * @param inValue value to add @@ -47,4 +71,30 @@ public class DoubleRange { return _max; } + + /** + * @return range, as maximum - minimum + */ + public double getRange() + { + return _max - _min; + } + + /** + * @return mid value, halfway between min and max + */ + public double getMidValue() + { + return (_max + _min) / 2.0; + } + + /** + * Copy this range into a new object, which can then be modified without changing this one + * @return deep copy of this object + */ + public DoubleRange copy() + { + if (_empty) return new DoubleRange(); + return new DoubleRange(_min, _max); + } }