Class BinMapper
java.lang.Object
uk.ac.starlink.ttools.plot2.layer.BinMapper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BinMappercreateMapper(boolean log, double binWidth, double binPhase, double point) Returns a BinMapper instance.abstract intgetBinIndex(double value) Returns the bin index for a given value.abstract double[]getBinLimits(int index) Returns the bin limits for a given bin index.static doublelog(double val) Logarithm function, used for transforming values on logarithmic X axis.
-
Constructor Details
-
BinMapper
public BinMapper()
-
-
Method Details
-
getBinIndex
public abstract int getBinIndex(double value) Returns the bin index for a given value. In case of an invalid value (NaN, or non-positive for log mapper), behaviour is undefined (quite likely zero will be returned).- Parameters:
value- valid axis value- Returns:
- bin index
-
getBinLimits
public abstract double[] getBinLimits(int index) Returns the bin limits for a given bin index.- Parameters:
index- bin index- Returns:
- (lower,upper) bin limits
-
createMapper
Returns a BinMapper instance.Notional bin boundaries are for
log=false:binWidth*(0+binPhase), binWidth*(1+binPhase), ...
and forlog=true:binWidth**(0+binPhase), binWidth**(1+binPhase), ...
The
pointparameter is used internally to determine the zero point of the bins. In principle this should make no difference to behaviour, but in case that the data is situated a very long way from 1, setting it close to the actual data point locations may avoid rounding errors.- Parameters:
log- false for linear axis scaling, true for logarithmicbinWidth- width of each bin; this is additive for linear and multiplicative for logarithmic scalingbinPhase- determines sub-bin boundary shifts along axis, normally in range 0..1point- representative point on axis near which bins are situated
-
log
public static double log(double val) Logarithm function, used for transforming values on logarithmic X axis.- Parameters:
val- value- Returns:
- log to base 10 of
val
-