Class Intervals
Intervals
.- Author:
- Tobias Pietzsch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final boolean
Test whether thecontaining
interval completely contains thecontained
interval.static boolean
contains
(Interval containing, Localizable contained) Test whether thecontaining
interval contains thecontained
point.static final boolean
contains
(RealInterval containing, RealInterval contained) Test whether thecontaining
interval completely contains thecontained
interval.static boolean
contains
(RealInterval containing, RealLocalizable contained) Test whether thecontaining
interval contains thecontained
point.static FinalInterval
createMinMax
(long... minmax) Create aFinalInterval
from a parameter list comprising minimum and maximum coordinates.static FinalRealInterval
createMinMaxReal
(double... minmax) Create aFinalRealInterval
from a parameter list comprising minimum and maximum coordinates.static FinalInterval
createMinSize
(long... minsize) Create aFinalInterval
from a parameter list comprising minimum coordinates and size.static FinalRealInterval
createMinSizeReal
(double... minsize) Deprecated.static int[]
dimensionsAsIntArray
(Dimensions dimensions) Create aint[]
with the dimensions of anInterval
.static long[]
dimensionsAsLongArray
(Dimensions dimensions) Create along[]
with the dimensions of aDimensions
.static boolean
equalDimensions
(Interval a, Interval b) Tests weather two intervals have equal dimensions (same size)static boolean
Tests weather two intervals are equal in their min / maxstatic FinalInterval
Grow/shrink an interval in all dimensions.static FinalInterval
Grow/shrink an interval in all dimensions.static FinalInterval
Grow/shrink an interval in one dimensions.static FinalInterval
expand
(Interval interval, Dimensions border) Grow/shrink an interval in all dimensions.static FinalInterval
Compute the intersection of two intervals.static FinalRealInterval
intersect
(RealInterval intervalA, RealInterval intervalB) Compute the intersection of two intervals.static boolean
Check whether the given interval is empty, that is, the maximum is smaller than the minimum in some dimension.static boolean
isEmpty
(RealInterval interval) Check whether the given interval is empty, that is, the maximum is smaller than the minimum in some dimension.static Interval
Compute the largestInterval
that is contained in the specifiedRealInterval
.static double[]
maxAsDoubleArray
(RealInterval interval) Create adouble[]
with the maximum of aRealInterval
.static int[]
maxAsIntArray
(Interval interval) Create aint[]
with the maximum of anInterval
.static long[]
maxAsLongArray
(Interval interval) Create along[]
with the maximum of anInterval
.static double[]
minAsDoubleArray
(RealInterval interval) Create adouble[]
with the minimum of aRealInterval
.static int[]
minAsIntArray
(Interval interval) Create aint[]
with the minimum of anInterval
.static long[]
minAsLongArray
(Interval interval) Create along[]
with the minimum of anInterval
.static long
numElements
(int... dimensions) Compute the number of elements contained in an (integer) interval.static long
numElements
(long... dimensions) Compute the number of elements contained in an (integer) interval.static long
numElements
(Dimensions interval) Compute the number of elements contained in an (integer)Interval
.static Interval
Compute the smallestInterval
containing the specifiedRealInterval
.static FinalInterval
Translate an interval in one dimension.static FinalInterval
Compute the smallest interval that contains both input intervals.static FinalRealInterval
union
(RealInterval intervalA, RealInterval intervalB) Compute the smallest interval that contains both input intervals.
-
Constructor Details
-
Intervals
public Intervals()
-
-
Method Details
-
createMinSize
Create aFinalInterval
from a parameter list comprising minimum coordinates and size. For example, to create a 2D interval from (10, 10) to (20, 40) use createMinSize( 10, 10, 11, 31 ).- Parameters:
minsize
- a list of 2*n parameters to create a n -dimensional interval. The first n parameters specify the minimum of the interval, the next n parameters specify the dimensions of the interval.- Returns:
- interval with the specified boundaries
-
createMinMax
Create aFinalInterval
from a parameter list comprising minimum and maximum coordinates. For example, to create a 2D interval from (10, 10) to (20, 40) use createMinMax( 10, 10, 20, 40 ).- Parameters:
minmax
- a list of 2*n parameters to create a n -dimensional interval. The first n parameters specify the minimum of the interval, the next n parameters specify the maximum of the interval.- Returns:
- interval with the specified boundaries
-
createMinSizeReal
Deprecated.THIS METHOD WILL BE REMOVED IN A FUTURE RELEASE. It was mistakenly introduced, analogous tocreateMinSize(long...)
for integer intervals. Dimension is not defined forRealInterval
and computing the max as min + dim - 1 does not make sense.Create a
FinalRealInterval
from a parameter list comprising minimum coordinates and size. For example, to create a 2D interval from (10, 10) to (20, 40) use createMinSize( 10, 10, 11, 31 ).- Parameters:
minsize
- a list of 2*n parameters to create a n -dimensional interval. The first n parameters specify the minimum of the interval, the next n parameters specify the dimensions of the interval.- Returns:
- interval with the specified boundaries
-
createMinMaxReal
Create aFinalRealInterval
from a parameter list comprising minimum and maximum coordinates. For example, to create a 2D interval from (10, 10) to (20, 40) use createMinMax( 10, 10, 20, 40 ).- Parameters:
minmax
- a list of 2*n parameters to create a n -dimensional interval. The first n parameters specify the minimum of the interval, the next n parameters specify the maximum of the interval.- Returns:
- interval with the specified boundaries
-
expand
Grow/shrink an interval in all dimensions. Create aFinalInterval
, which is the input interval plus border pixels on every side, in every dimension.- Parameters:
interval
- the input intervalborder
- how many pixels to add on every side- Returns:
- expanded interval
-
expand
Grow/shrink an interval in all dimensions. Create aFinalInterval
, which is the input interval plus border pixels on every side, in every dimension.- Parameters:
interval
- the input intervalborder
- how many pixels to add on every side- Returns:
- expanded interval
-
expand
Grow/shrink an interval in all dimensions. Create aFinalInterval
, which is the input interval plus border pixels on every side, in every dimension.- Parameters:
interval
- the input intervalborder
- how many pixels to add on every side- Returns:
- expanded interval
-
expand
Grow/shrink an interval in one dimensions. Create aFinalInterval
, which is the input interval plus border pixels on every side, in dimension d.- Parameters:
interval
- the input intervalborder
- how many pixels to add on every sided
- in which dimension- Returns:
- expanded interval
-
translate
Translate an interval in one dimension. Create aFinalInterval
, which is the input interval shifted by t in dimension d.- Parameters:
interval
- the input intervalt
- by how many pixels to shift the intervald
- in which dimension- Returns:
- translated interval
-
intersect
Compute the intersection of two intervals. Create aFinalInterval
, which is the intersection of the input intervals (i.e., the area contained in both input intervals).- Parameters:
intervalA
- input intervalintervalB
- input interval- Returns:
- intersection of input intervals
-
intersect
Compute the intersection of two intervals. Create aRealInterval
, which is the intersection of the input intervals (i.e., the area contained in both input intervals).- Parameters:
intervalA
- input intervalintervalB
- input interval- Returns:
- intersection of input intervals
-
union
Compute the smallest interval that contains both input intervals. Create aFinalInterval
that represents that interval.- Parameters:
intervalA
- input intervalintervalB
- input interval- Returns:
- union of input intervals
-
union
Compute the smallest interval that contains both input intervals. Create aRealInterval
that represents that interval.- Parameters:
intervalA
- input intervalintervalB
- input interval- Returns:
- union of input intervals
-
smallestContainingInterval
Compute the smallestInterval
containing the specifiedRealInterval
.- Parameters:
ri
- input interval.- Returns:
- the smallest integer interval that completely contains the input interval.
-
largestContainedInterval
Compute the largestInterval
that is contained in the specifiedRealInterval
.- Parameters:
ri
- input interval.- Returns:
- the largest integer interval that is completely contained in the input interval.
-
isEmpty
Check whether the given interval is empty, that is, the maximum is smaller than the minimum in some dimension.- Parameters:
interval
- interval to check- Returns:
- true when the interval is empty, that is, the maximum is smaller than the minimum in some dimension.
-
isEmpty
Check whether the given interval is empty, that is, the maximum is smaller than the minimum in some dimension.- Parameters:
interval
- interval to check- Returns:
- true when the interval is empty, that is, the maximum is smaller than the minimum in some dimension.
-
contains
Test whether thecontaining
interval contains thecontained
point. The interval is closed, that is, boundary points are contained.- Returns:
- true, iff
contained
is incontaining
.
-
contains
Test whether thecontaining
interval contains thecontained
point. The interval is closed, that is, boundary points are contained.- Returns:
- true, iff
contained
is incontaining
.
-
contains
Test whether thecontaining
interval completely contains thecontained
interval. -
contains
Test whether thecontaining
interval completely contains thecontained
interval. -
numElements
Compute the number of elements contained in an (integer)Interval
.- Returns:
- number of elements in
interval
.
-
numElements
public static long numElements(int... dimensions) Compute the number of elements contained in an (integer) interval.- Parameters:
dimensions
- dimensions of the interval.- Returns:
- number of elements in the interval.
-
numElements
public static long numElements(long... dimensions) Compute the number of elements contained in an (integer) interval.- Parameters:
dimensions
- dimensions of the interval.- Returns:
- number of elements in the interval.
-
equals
Tests weather two intervals are equal in their min / max -
equalDimensions
Tests weather two intervals have equal dimensions (same size) -
dimensionsAsLongArray
Create along[]
with the dimensions of aDimensions
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly. See
Dimensions.dimensions(long[])
.- Parameters:
dimensions
- something which has dimensions- Returns:
- dimensions as a new
long[]
-
dimensionsAsIntArray
Create aint[]
with the dimensions of anInterval
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly.
- Parameters:
dimensions
- something which has dimensions- Returns:
- dimensions as a new
int[]
-
minAsLongArray
Create along[]
with the minimum of anInterval
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly. See
Interval.min(long[])
.- Parameters:
interval
- something with interval boundaries- Returns:
- minimum as a new
long[]
-
minAsIntArray
Create aint[]
with the minimum of anInterval
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly.
- Parameters:
interval
- something with interval boundaries- Returns:
- minimum as a new
int[]
-
maxAsLongArray
Create along[]
with the maximum of anInterval
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly. See
Interval.max(long[])
.- Parameters:
interval
- something with interval boundaries- Returns:
- maximum as a new
long[]
-
maxAsIntArray
Create aint[]
with the maximum of anInterval
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly.
- Parameters:
interval
- something with interval boundaries- Returns:
- maximum as a new
int[]
-
maxAsDoubleArray
Create adouble[]
with the maximum of aRealInterval
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly. See
RealInterval.realMax(double[])
.- Parameters:
interval
- something with interval boundaries- Returns:
- maximum as a new double[]
-
minAsDoubleArray
Create adouble[]
with the minimum of aRealInterval
.Keep in mind that creating arrays wildly is not good practice and consider using the interval directly. See
RealInterval.realMin(double[])
.- Parameters:
interval
- something with interval boundaries- Returns:
- minimum as a new double[]
-