public class RealRange extends Object implements EuclidConstants, Comparable<RealRange>
Default is range with low > high; this can be regarded as the uninitialised state. If points are added to a default RealRange it becomes initialised.
| Modifier and Type | Class and Description |
|---|---|
static class |
RealRange.Direction |
| Modifier and Type | Field and Description |
|---|---|
protected double |
maxval
maximum of range
|
protected double |
minval
minimum of range
|
C_AMP, C_APOS, C_ATSIGN, C_BACKSLASH, C_BACKSPACE, C_CARET, C_COLON, C_COMMA, C_DEL, C_DOLLAR, C_EQUALS, C_FORMFEED, C_HASH, C_LANGLE, C_LBRAK, C_LCURLY, C_LSQUARE, C_MINUS, C_NBSP, C_NEWLINE, C_NL, C_PERCENT, C_PERIOD, C_PIPE, C_PLUS, C_POUND, C_QUERY, C_QUOT, C_RANGLE, C_RBRAK, C_RCURLY, C_RETURN, C_RSQUARE, C_SEMICOLON, C_SHRIEK, C_SLASH, C_SPACE, C_STAR, C_TAB, C_TILDE, C_UNDER, EPS, F_S, NONWHITEPUNC, NONWHITEPUNC0, NONWHITEPUNC0REGEX, ONE_THIRD, PUNC, S_AMP, S_APOS, S_ATSIGN, S_BACKSLASH, S_CARET, S_COLON, S_COMMA, S_DOLLAR, S_EMPTY, S_EQUALS, S_FORMFEED, S_HASH, S_LANGLE, S_LBRAK, S_LCURLY, S_LSQUARE, S_MINUS, S_NEWLINE, S_NL, S_PERCENT, S_PERIOD, S_PIPE, S_PLUS, S_POUND, S_QUERY, S_QUOT, S_RANGLE, S_RBRAK, S_RCURLY, S_RETURN, S_RSQUARE, S_SEMICOLON, S_SHRIEK, S_SLASH, S_SPACE, S_STAR, S_TAB, S_TILDE, S_UNDER, S_WHITEREGEX, TWO_THIRDS, U_S, WHITESPACE| Constructor and Description |
|---|
RealRange()
creates invalid range from POSITIVE_INFINITY to NEGATIVE_INFINITY
|
RealRange(double minv,
double maxv)
initialise with min and max values; if minv > maxv create inValid
RealRange
|
RealRange(double minv,
double maxv,
boolean normalize)
initialise with min and max values; if minv > maxv create inValid
RealRange
|
RealRange(IntRange ir)
from an IntRange
|
RealRange(RealRange r)
copy constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(double x)
add a value to a range
|
int |
compareTo(RealRange realRange)
comparees on min values
|
boolean |
contains(double f)
synonym for includes()
|
static List<RealRange> |
createRealRangeList(List<String> tokens)
creates a list of RealRanges from {...} syntax.
|
double |
distanceOutside(double d)
gets minimum signed translation required to move point into range
If range=(-1, 10)
-3 returns 2
-1 returns 0
3 returns 0
10 returns 0
12 returns -2
|
boolean |
equals(Object o)
use with care as uses ==
|
void |
extendBothEndsBy(double tolerance)
subtracts tolerance from min and adds to max
if tolerance is negative adds and subtracts
if this would result in maxval < minval sets them to mean
|
void |
extendLowerEndBy(double tolerance)
extend minval
|
void |
extendUpperEndBy(double tolerance)
extend maxval
|
RealRange |
format(Integer decimalPlaces) |
double |
getMax()
get maximum value (NEGATIVE_INFINITY if inValid)
|
double |
getMidPoint()
get centroid value (NEGATIVE_INFINITY if inValid)
|
double |
getMin()
get minimum value (POSITIVE_INFINITY if inValid)
|
double |
getRandomVariate()
return a number uniformaly distributed within the range.
|
double |
getRange()
get range (NaN if invalid)
|
static RealRange |
getRange(String s) |
RealRange |
getRangeExtendedBy(double minExtend,
double maxExtend)
makes new RealRange extended by deltaMin and deltaMax.
|
Double |
getScaleTo(RealRange range)
get scale to convert this range to same extent as other.
|
int |
hashCode() |
boolean |
includes(double f)
is a double within a RealRange
If inValid, return false
|
boolean |
includes(RealRange r2)
does one range include another
|
RealRange |
intersectionWith(RealRange r2)
intersect two ranges and take the range common to both;
return null if no overlap
|
boolean |
intersectsWith(RealRange r2) |
static boolean |
isEqual(RealRange range0,
RealRange range1,
double eps) |
boolean |
isEqualTo(RealRange r)
Deprecated.
|
boolean |
isEqualTo(RealRange r,
double eps)
invalid ranges return false
|
boolean |
isLessThan(RealRange range)
compares ranges independent of origin.
|
boolean |
isValid()
a Range is only valid if its maxval is not less than its minval; this
tests for uninitialised ranges
|
void |
normalize()
if min > max swap them
|
static RealRange |
parseCurlyBracketString(String token)
interprets a String as an RealRange.
|
RealRange |
plus(RealRange r2)
combine two ranges if both valid; takes greatest limits of both, else
returns InValid
|
RealRange |
plusEquals(RealRange r2) |
void |
setRange(double minv,
double maxv)
sets range.
|
String |
toString()
to string.
|
protected double maxval
protected double minval
public RealRange()
public RealRange(double minv,
double maxv)
minv - maxv - public RealRange(double minv,
double maxv,
boolean normalize)
minv - maxv - normalize - swap params if min > maxpublic RealRange(RealRange r)
r - public RealRange(IntRange ir)
ir - public void setRange(double minv,
double maxv)
minv - maxv - public boolean isValid()
@Deprecated public boolean isEqualTo(RealRange r)
r - public boolean isEqualTo(RealRange r, double eps)
r - public RealRange plus(RealRange r2)
r2 - public boolean intersectsWith(RealRange r2)
public RealRange intersectionWith(RealRange r2)
r2 - public double getMin()
public double getMax()
public double getMidPoint()
public double getRange()
public boolean includes(RealRange r2)
r2 - public boolean includes(double f)
f - public boolean contains(double f)
f - public void add(double x)
x - public double getRandomVariate()
public Double getScaleTo(RealRange range)
range - to scale topublic void normalize()
public double distanceOutside(double d)
d - public String toString()
public int compareTo(RealRange realRange)
compareTo in interface Comparable<RealRange>realRange - public void extendBothEndsBy(double tolerance)
tolerance - public void extendLowerEndBy(double tolerance)
tolerance - if negative cannot get larger than maxvalpublic void extendUpperEndBy(double tolerance)
tolerance - if negative cannot get lower than minvalpublic RealRange getRangeExtendedBy(double minExtend, double maxExtend)
Does not alter this.
minExtend - subtracted from minmaxExtend - added to maxpublic static RealRange parseCurlyBracketString(String token)
token - public static List<RealRange> createRealRangeList(List<String> tokens)
tokens - public boolean isLessThan(RealRange range)
range - Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.