Top Description Inners Fields Constructors Methods
org.apache.commons.math3.geometry.euclidean.oned

public Class IntervalsSet

extends AbstractRegion<Euclidean1D, Euclidean1D>
implements Iterable<double[]>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Imports
java.util.ArrayList, .Collection, .Iterator, .List, .NoSuchElementException, org.apache.commons.math3.geometry.Point, org.apache.commons.math3.geometry.partitioning.AbstractRegion, .BSPTree, .BoundaryProjection, .SubHyperplane, org.apache.commons.math3.util.Precision

This class represents a 1D region: a set of intervals.
Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
IntervalsSet.SubIntervalsIterator

Local iterator for sub-intervals.

Field Summary

Modifier and TypeField and Description
private static final double
DEFAULT_TOLERANCE

Default value for tolerance.

Constructor Summary

AccessConstructor and Description
public
IntervalsSet(final double
tolerance below which points are considered identical.
tolerance
)

Build an intervals set representing the whole real line.

public
IntervalsSet(final double
lower bound of the interval, must be lesser or equal to upper (may be Double.NEGATIVE_INFINITY)
lower
,
final double
upper bound of the interval, must be greater or equal to lower (may be Double.POSITIVE_INFINITY)
upper
,
final double
tolerance below which points are considered identical.
tolerance
)

Build an intervals set corresponding to a single interval.

public
IntervalsSet(final BSPTree<Euclidean1D>
inside/outside BSP tree representing the intervals set
tree
,
final double
tolerance below which points are considered identical.
tolerance
)

Build an intervals set from an inside/outside BSP tree.

public
IntervalsSet(final Collection<SubHyperplane<Euclidean1D>>
collection of boundary elements
boundary
,
final double
tolerance below which points are considered identical.
tolerance
)

Build an intervals set from a Boundary REPresentation (B-rep).

public
IntervalsSet()
Deprecated as of 3.1 replaced with IntervalsSet(double)

Build an intervals set representing the whole real line.

public
IntervalsSet(final double
lower bound of the interval, must be lesser or equal to upper (may be Double.NEGATIVE_INFINITY)
lower
,
final double
upper bound of the interval, must be greater or equal to lower (may be Double.POSITIVE_INFINITY)
upper
)
Deprecated as of 3.3 replaced with IntervalsSet(double, double, double)

Build an intervals set corresponding to a single interval.

public
IntervalsSet(final BSPTree<Euclidean1D>
inside/outside BSP tree representing the intervals set
tree
)
Deprecated as of 3.3, replaced with IntervalsSet(BSPTree, double)

Build an intervals set from an inside/outside BSP tree.

public
IntervalsSet(final Collection<SubHyperplane<Euclidean1D>>
collection of boundary elements
boundary
)
Deprecated as of 3.3, replaced with IntervalsSet(Collection, double)

Build an intervals set from a Boundary REPresentation (B-rep).

Method Summary

Modifier and TypeMethod and Description
public List<Interval>

Returns:

a new ordered list containing Interval elements
asList
()

Build an ordered list of intervals representing the instance.

public IntervalsSet
buildNew(final BSPTree<Euclidean1D>
inside/outside BSP tree representing the new region
tree
)

Implements abstract org.apache.commons.math3.geometry.partitioning.AbstractRegion.buildNew.

Implements org.apache.commons.math3.geometry.partitioning.Region.buildNew.

Build a region using the instance as a prototype.

private static BSPTree<Euclidean1D>

Returns:

the built tree
buildTree
(final double
lower bound of the interval, must be lesser or equal to upper (may be Double.NEGATIVE_INFINITY)
lower
,
final double
upper bound of the interval, must be greater or equal to lower (may be Double.POSITIVE_INFINITY)
upper
,
final double
tolerance below which points are considered identical.
tolerance
)

Build an inside/outside tree representing a single interval.

private BSPTree<Euclidean1D>

Returns:

child node just after the internal node
childAfter
(BSPTree<Euclidean1D>
internal node at which the sub-tree starts
node
)

Find the child node just after an internal node.

private BSPTree<Euclidean1D>

Returns:

child node just before the internal node
childBefore
(BSPTree<Euclidean1D>
internal node at which the sub-tree starts
node
)

Find the child node just before an internal node.

protected void
private Vector1D

Returns:

a new point for finite abscissa, null otherwise
finiteOrNullPoint
(final double
abscissa of the point
x
)

Build a finite point.

private double

Returns:

abscissa
getAngle
(final BSPTree<Euclidean1D>
internal node to check
node
)

Get the abscissa of an internal node.

private BSPTree<Euclidean1D>

Returns:

smallest internal node, or null if there are no internal nodes (i.e. the set is either empty or covers the real line)
getFirstIntervalBoundary
()

Get the node corresponding to the first interval boundary.

private BSPTree<Euclidean1D>

Returns:

first leaf node
getFirstLeaf
(final BSPTree<Euclidean1D>
tree root
root
)

Get the first leaf node of a tree.

public double

Returns:

lowest value belonging to the instance (Double.NEGATIVE_INFINITY if the instance doesn't have any low bound, Double.POSITIVE_INFINITY if the instance is empty)
getInf
()

Get the lowest value belonging to the instance.

public double

Returns:

highest value belonging to the instance (Double.POSITIVE_INFINITY if the instance doesn't have any high bound, Double.NEGATIVE_INFINITY if the instance is empty)
getSup
()

Get the highest value belonging to the instance.

private boolean

Returns:

true is the node has a parent end is after it in ascending order
isAfterParent
(final BSPTree<Euclidean1D>
child node considered
node
)

Check if a node is the child after its parent in ascending order.

private boolean

Returns:

true is the node has a parent end is before it in ascending order
isBeforeParent
(final BSPTree<Euclidean1D>
child node considered
node
)

Check if a node is the child before its parent in ascending order.

private boolean

Returns:

true if the oriented point is direct
isDirect
(final BSPTree<Euclidean1D>
internal node to check
node
)

Check if an internal node has a direct oriented point.

private boolean

Returns:

true if the node corresponds to the end abscissa of an interval
isIntervalEnd
(final BSPTree<Euclidean1D>
internal node to check
node
)

Check if an internal node corresponds to the end abscissa of an interval.

private boolean

Returns:

true if the node corresponds to the start abscissa of an interval
isIntervalStart
(final BSPTree<Euclidean1D>
internal node to check
node
)

Check if an internal node corresponds to the start abscissa of an interval.

public Iterator<double[]>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

private BSPTree<Euclidean1D>

Returns:

leaf node just after the internal node
leafAfter
(BSPTree<Euclidean1D>
internal node at which the sub-tree starts
node
)

Find the leaf node just after an internal node.

private BSPTree<Euclidean1D>

Returns:

leaf node just before the internal node
leafBefore
(BSPTree<Euclidean1D>
internal node at which the sub-tree starts
node
)

Find the leaf node just before an internal node.

private BSPTree<Euclidean1D>

Returns:

next internal node in ascending order, or null if this is the last internal node
nextInternalNode
(BSPTree<Euclidean1D>
current internal node
node
)

Get the next internal node.

private BSPTree<Euclidean1D>

Returns:

previous internal node in ascending order, or null if this is the first internal node
previousInternalNode
(BSPTree<Euclidean1D>
current internal node
node
)

Get the previous internal node.

public BoundaryProjection<Euclidean1D>
Inherited from org.apache.commons.math3.geometry.partitioning.AbstractRegion:
applyTransformcheckPointcheckPointcheckPointcheckPointcontainscopySelfgetBarycentergetBoundarySizegetSizegetTolerancegetTreeintersectionisEmptyisEmptyisFullisFullsetBarycentersetBarycentersetSizeside

Field Detail

DEFAULT_TOLERANCEback to summary
private static final double DEFAULT_TOLERANCE

Default value for tolerance.

Constructor Detail

IntervalsSetback to summary
public IntervalsSet(final double tolerance)

Build an intervals set representing the whole real line.

Parameters
tolerance:double

tolerance below which points are considered identical.

Since
3.3
IntervalsSetback to summary
public IntervalsSet(final double lower, final double upper, final double tolerance)

Build an intervals set corresponding to a single interval.

Parameters
lower:double

lower bound of the interval, must be lesser or equal to upper (may be Double.NEGATIVE_INFINITY)

upper:double

upper bound of the interval, must be greater or equal to lower (may be Double.POSITIVE_INFINITY)

tolerance:double

tolerance below which points are considered identical.

Since
3.3
IntervalsSetback to summary
public IntervalsSet(final BSPTree<Euclidean1D> tree, final double tolerance)

Build an intervals set from an inside/outside BSP tree.

The leaf nodes of the BSP tree must have a Boolean attribute representing the inside status of the corresponding cell (true for inside cells, false for outside cells). In order to avoid building too many small objects, it is recommended to use the predefined constants Boolean.TRUE and Boolean.FALSE

Parameters
tree:BSPTree<Euclidean1D>

inside/outside BSP tree representing the intervals set

tolerance:double

tolerance below which points are considered identical.

Since
3.3
IntervalsSetback to summary
public IntervalsSet(final Collection<SubHyperplane<Euclidean1D>> boundary, final double tolerance)

Build an intervals set from a Boundary REPresentation (B-rep).

The boundary is provided as a collection of sub-hyperplanes. Each sub-hyperplane has the interior part of the region on its minus side and the exterior on its plus side.

The boundary elements can be in any order, and can form several non-connected sets (like for example polygons with holes or a set of disjoints polyhedrons considered as a whole). In fact, the elements do not even need to be connected together (their topological connections are not used here). However, if the boundary does not really separate an inside open from an outside open (open having here its topological meaning), then subsequent calls to the checkPoint method will not be meaningful anymore.

If the boundary is empty, the region will represent the whole space.

Parameters
boundary:Collection<SubHyperplane<Euclidean1D>>

collection of boundary elements

tolerance:double

tolerance below which points are considered identical.

Since
3.3
IntervalsSetback to summary
public IntervalsSet()

Deprecated

as of 3.1 replaced with IntervalsSet(double)

Build an intervals set representing the whole real line.

Annotations
@Deprecated
IntervalsSetback to summary
public IntervalsSet(final double lower, final double upper)

Deprecated

as of 3.3 replaced with IntervalsSet(double, double, double)

Build an intervals set corresponding to a single interval.

Parameters
lower:double

lower bound of the interval, must be lesser or equal to upper (may be Double.NEGATIVE_INFINITY)

upper:double

upper bound of the interval, must be greater or equal to lower (may be Double.POSITIVE_INFINITY)

Annotations
@Deprecated
IntervalsSetback to summary
public IntervalsSet(final BSPTree<Euclidean1D> tree)

Deprecated

as of 3.3, replaced with IntervalsSet(BSPTree, double)

Build an intervals set from an inside/outside BSP tree.

The leaf nodes of the BSP tree must have a Boolean attribute representing the inside status of the corresponding cell (true for inside cells, false for outside cells). In order to avoid building too many small objects, it is recommended to use the predefined constants Boolean.TRUE and Boolean.FALSE

Parameters
tree:BSPTree<Euclidean1D>

inside/outside BSP tree representing the intervals set

Annotations
@Deprecated
IntervalsSetback to summary
public IntervalsSet(final Collection<SubHyperplane<Euclidean1D>> boundary)

Deprecated

as of 3.3, replaced with IntervalsSet(Collection, double)

Build an intervals set from a Boundary REPresentation (B-rep).

The boundary is provided as a collection of sub-hyperplanes. Each sub-hyperplane has the interior part of the region on its minus side and the exterior on its plus side.

The boundary elements can be in any order, and can form several non-connected sets (like for example polygons with holes or a set of disjoints polyhedrons considered as a whole). In fact, the elements do not even need to be connected together (their topological connections are not used here). However, if the boundary does not really separate an inside open from an outside open (open having here its topological meaning), then subsequent calls to the checkPoint method will not be meaningful anymore.

If the boundary is empty, the region will represent the whole space.

Parameters
boundary:Collection<SubHyperplane<Euclidean1D>>

collection of boundary elements

Annotations
@Deprecated

Method Detail

asListback to summary
public List<Interval> asList()

Build an ordered list of intervals representing the instance.

This method builds this intervals set as an ordered list of Interval elements. If the intervals set has no lower limit, the first interval will have its low bound equal to Double.NEGATIVE_INFINITY. If the intervals set has no upper limit, the last interval will have its upper bound equal to Double.POSITIVE_INFINITY. An empty tree will build an empty list while a tree representing the whole real line will build a one element list with both bounds being infinite.

Returns:List<Interval>

a new ordered list containing Interval elements

buildNewback to summary
public IntervalsSet buildNew(final BSPTree<Euclidean1D> tree)

Implements abstract org.apache.commons.math3.geometry.partitioning.AbstractRegion.buildNew.

Implements org.apache.commons.math3.geometry.partitioning.Region.buildNew.

Doc from org.apache.commons.math3.geometry.partitioning.AbstractRegion.buildNew.

Build a region using the instance as a prototype.

This method allow to create new instances without knowing exactly the type of the region. It is an application of the prototype design pattern.

The leaf nodes of the BSP tree must have a Boolean attribute representing the inside status of the corresponding cell (true for inside cells, false for outside cells). In order to avoid building too many small objects, it is recommended to use the predefined constants Boolean.TRUE and Boolean.FALSE. The tree also must have either null internal nodes or internal nodes representing the boundary as specified in the getTree method).

Parameters
tree:BSPTree<Euclidean1D>

Doc from org.apache.commons.math3.geometry.partitioning.Region.buildNew.

inside/outside BSP tree representing the new region

Returns:IntervalsSet

Doc from org.apache.commons.math3.geometry.partitioning.Region.buildNew.

the built region

Annotations
@Override
buildTreeback to summary
private static BSPTree<Euclidean1D> buildTree(final double lower, final double upper, final double tolerance)

Build an inside/outside tree representing a single interval.

Parameters
lower:double

lower bound of the interval, must be lesser or equal to upper (may be Double.NEGATIVE_INFINITY)

upper:double

upper bound of the interval, must be greater or equal to lower (may be Double.POSITIVE_INFINITY)

tolerance:double

tolerance below which points are considered identical.

Returns:BSPTree<Euclidean1D>

the built tree

childAfterback to summary
private BSPTree<Euclidean1D> childAfter(BSPTree<Euclidean1D> node)

Find the child node just after an internal node.

Parameters
node:BSPTree<Euclidean1D>

internal node at which the sub-tree starts

Returns:BSPTree<Euclidean1D>

child node just after the internal node

childBeforeback to summary
private BSPTree<Euclidean1D> childBefore(BSPTree<Euclidean1D> node)

Find the child node just before an internal node.

Parameters
node:BSPTree<Euclidean1D>

internal node at which the sub-tree starts

Returns:BSPTree<Euclidean1D>

child node just before the internal node

computeGeometricalPropertiesback to summary
protected void computeGeometricalProperties()

Implements abstract org.apache.commons.math3.geometry.partitioning.AbstractRegion.computeGeometricalProperties.

Doc from org.apache.commons.math3.geometry.partitioning.AbstractRegion.computeGeometricalProperties.

Compute some geometrical properties.

The properties to compute are the barycenter and the size.

Annotations
@Override
finiteOrNullPointback to summary
private Vector1D finiteOrNullPoint(final double x)

Build a finite point.

Parameters
x:double

abscissa of the point

Returns:Vector1D

a new point for finite abscissa, null otherwise

getAngleback to summary
private double getAngle(final BSPTree<Euclidean1D> node)

Get the abscissa of an internal node.

Parameters
node:BSPTree<Euclidean1D>

internal node to check

Returns:double

abscissa

getFirstIntervalBoundaryback to summary
private BSPTree<Euclidean1D> getFirstIntervalBoundary()

Get the node corresponding to the first interval boundary.

Returns:BSPTree<Euclidean1D>

smallest internal node, or null if there are no internal nodes (i.e. the set is either empty or covers the real line)

getFirstLeafback to summary
private BSPTree<Euclidean1D> getFirstLeaf(final BSPTree<Euclidean1D> root)

Get the first leaf node of a tree.

Parameters
root:BSPTree<Euclidean1D>

tree root

Returns:BSPTree<Euclidean1D>

first leaf node

getInfback to summary
public double getInf()

Get the lowest value belonging to the instance.

Returns:double

lowest value belonging to the instance (Double.NEGATIVE_INFINITY if the instance doesn't have any low bound, Double.POSITIVE_INFINITY if the instance is empty)

getSupback to summary
public double getSup()

Get the highest value belonging to the instance.

Returns:double

highest value belonging to the instance (Double.POSITIVE_INFINITY if the instance doesn't have any high bound, Double.NEGATIVE_INFINITY if the instance is empty)

isAfterParentback to summary
private boolean isAfterParent(final BSPTree<Euclidean1D> node)

Check if a node is the child after its parent in ascending order.

Parameters
node:BSPTree<Euclidean1D>

child node considered

Returns:boolean

true is the node has a parent end is after it in ascending order

isBeforeParentback to summary
private boolean isBeforeParent(final BSPTree<Euclidean1D> node)

Check if a node is the child before its parent in ascending order.

Parameters
node:BSPTree<Euclidean1D>

child node considered

Returns:boolean

true is the node has a parent end is before it in ascending order

isDirectback to summary
private boolean isDirect(final BSPTree<Euclidean1D> node)

Check if an internal node has a direct oriented point.

Parameters
node:BSPTree<Euclidean1D>

internal node to check

Returns:boolean

true if the oriented point is direct

isIntervalEndback to summary
private boolean isIntervalEnd(final BSPTree<Euclidean1D> node)

Check if an internal node corresponds to the end abscissa of an interval.

Parameters
node:BSPTree<Euclidean1D>

internal node to check

Returns:boolean

true if the node corresponds to the end abscissa of an interval

isIntervalStartback to summary
private boolean isIntervalStart(final BSPTree<Euclidean1D> node)

Check if an internal node corresponds to the start abscissa of an interval.

Parameters
node:BSPTree<Euclidean1D>

internal node to check

Returns:boolean

true if the node corresponds to the start abscissa of an interval

iteratorback to summary
public Iterator<double[]> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

The iterator returns the limit values of sub-intervals in ascending order.

The iterator does not support the optional remove operation.

Returns:Iterator<double[]>

an Iterator.

Since
3.3
leafAfterback to summary
private BSPTree<Euclidean1D> leafAfter(BSPTree<Euclidean1D> node)

Find the leaf node just after an internal node.

Parameters
node:BSPTree<Euclidean1D>

internal node at which the sub-tree starts

Returns:BSPTree<Euclidean1D>

leaf node just after the internal node

leafBeforeback to summary
private BSPTree<Euclidean1D> leafBefore(BSPTree<Euclidean1D> node)

Find the leaf node just before an internal node.

Parameters
node:BSPTree<Euclidean1D>

internal node at which the sub-tree starts

Returns:BSPTree<Euclidean1D>

leaf node just before the internal node

nextInternalNodeback to summary
private BSPTree<Euclidean1D> nextInternalNode(BSPTree<Euclidean1D> node)

Get the next internal node.

Parameters
node:BSPTree<Euclidean1D>

current internal node

Returns:BSPTree<Euclidean1D>

next internal node in ascending order, or null if this is the last internal node

previousInternalNodeback to summary
private BSPTree<Euclidean1D> previousInternalNode(BSPTree<Euclidean1D> node)

Get the previous internal node.

Parameters
node:BSPTree<Euclidean1D>

current internal node

Returns:BSPTree<Euclidean1D>

previous internal node in ascending order, or null if this is the first internal node

projectToBoundaryback to summary
public BoundaryProjection<Euclidean1D> projectToBoundary(final Point<Euclidean1D> point)

Overrides org.apache.commons.math3.geometry.partitioning.AbstractRegion.projectToBoundary.

Implements org.apache.commons.math3.geometry.partitioning.Region.projectToBoundary.

Doc from org.apache.commons.math3.geometry.partitioning.AbstractRegion.projectToBoundary.

Project a point on the boundary of the region.

Parameters
point:Point<Euclidean1D>

Doc from org.apache.commons.math3.geometry.partitioning.Region.projectToBoundary.

point to check

Returns:BoundaryProjection<Euclidean1D>

Doc from org.apache.commons.math3.geometry.partitioning.Region.projectToBoundary.

projection of the point on the boundary

Annotations
@Override
Since
3.3
org.apache.commons.math3.geometry.euclidean.oned back to summary

private Class IntervalsSet.SubIntervalsIterator

extends Object
implements Iterator<double[]>
Class Inheritance
  • java.lang.Object
  • org.apache.commons.math3.geometry.euclidean.oned.IntervalsSet.SubIntervalsIterator
All Implemented Interfaces
java.util.Iterator

Local iterator for sub-intervals.

Field Summary

Modifier and TypeField and Description
private BSPTree<Euclidean1D>
current

Current node.

private double[]
pending

Sub-interval no yet returned.

Constructor Summary

AccessConstructor and Description
pack-priv
SubIntervalsIterator()

Simple constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public double[]
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).

private void
selectPending()

Walk the tree to select the pending sub-interval.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private BSPTree<Euclidean1D> current

Current node.

pendingback to summary
private double[] pending

Sub-interval no yet returned.

Constructor Detail

SubIntervalsIteratorback to summary
pack-priv SubIntervalsIterator()

Simple constructor.

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

nextback to summary
public double[] next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:double[]

the next element in the iteration

removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.

selectPendingback to summary
private void selectPending()

Walk the tree to select the pending sub-interval.