Top Description Inners Methods
org.apache.commons.math3.geometry.partitioning

public Interface Region<S extends Space>

Known Direct Implementers
org.apache.commons.math3.geometry.partitioning.AbstractRegion
Type Parameters
<S>
Type of the space.
Imports
org.apache.commons.math3.geometry.Space, .Point

This interface represents a region of a space as a partition.

Region are subsets of a space, they can be infinite (whole space, half space, infinite stripe ...) or finite (polygons in 2D, polyhedrons in 3D ...). Their main characteristic is to separate points that are considered to be inside the region from points considered to be outside of it. In between, there may be points on the boundary of the region.

This implementation is limited to regions for which the boundary is composed of several sub-hyperplanes, including regions with no boundary at all: the whole space and the empty region. They are not necessarily finite and not necessarily path-connected. They can contain holes.

Regions can be combined using the traditional sets operations : union, intersection, difference and symetric difference (exclusive or) for the binary operations, complement for the unary operation.

Note that this interface is not intended to be implemented by Apache Commons Math users, it is only intended to be implemented within the library itself. New methods may be added even for minor versions, which breaks compatibility for external implementations.

Since
3.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Region.Location

Enumerate for the location of a point with respect to the region.

Method Summary

Modifier and TypeMethod and Description
public Region<S>

Returns:

the built region
buildNew
(BSPTree<S>
inside/outside BSP tree representing the new region
newTree
)

Build a region using the instance as a prototype.

public Region.Location

Returns:

a code representing the point status: either Location#INSIDE, Location#OUTSIDE or Location#BOUNDARY
checkPoint
(final Point<S>
point to check
point
)

Check a point with respect to the region.

public boolean

Returns:

true if the instance contains the specified tree
contains
(final Region<S>
region to check against the instance
region
)

Check if the instance entirely contains another region.

public Region<S>

Returns:

a new region, copy of the instance
copySelf
()

Copy the instance.

public Point<S>

Returns:

an object representing the barycenter
getBarycenter
()

Get the barycenter of the instance.

public double

Returns:

the size of the boundary (this is 0 in 1D, a length in 2D, an area in 3D ...)
getBoundarySize
()

Get the size of the boundary.

public double

Returns:

the size of the instance (this is a length in 1D, an area in 2D, a volume in 3D ...)
getSize
()

Get the size of the instance.

public BSPTree<S>

Returns:

underlying BSP tree
getTree
(final boolean
if true, the boundary attributes at internal nodes are guaranteed to be included (they may be included even if the argument is false, if they have already been computed due to a previous call)
includeBoundaryAttributes
)

Get the underlying BSP tree.

public SubHyperplane<S>

Returns:

filtered sub-hyperplane
intersection
(final SubHyperplane<S>
sub-hyperplane traversing the region
sub
)

Get the parts of a sub-hyperplane that are contained in the region.

public boolean

Returns:

true if the instance is empty
isEmpty
()

Check if the instance is empty.

public boolean

Returns:

true if the sub-tree starting at the given node is empty
isEmpty
(final BSPTree<S>
root node of the sub-tree (must have Region tree semantics, i.e. the leaf nodes must have Boolean attributes representing an inside/outside property)
node
)

Check if the sub-tree starting at a given node is empty.

public boolean

Returns:

true if the instance covers the full space
isFull
()

Check if the instance covers the full space.

public boolean

Returns:

true if the sub-tree starting at the given node covers the full space
isFull
(final BSPTree<S>
root node of the sub-tree (must have Region tree semantics, i.e. the leaf nodes must have Boolean attributes representing an inside/outside property)
node
)

Check if the sub-tree starting at a given node covers the full space.

public BoundaryProjection<S>

Returns:

projection of the point on the boundary
projectToBoundary
(final Point<S>
point to check
point
)

Project a point on the boundary of the region.

public Side

Returns:

one of Side.PLUS, Side.MINUS, Side.BOTH or Side.HYPER (the latter result can occur only if the tree contains only one cut hyperplane)
side
(final Hyperplane<S>
reference hyperplane
hyperplane
)
Deprecated as of 3.6, this method which was only intended for internal use is not used anymore

Compute the relative position of the instance with respect to an hyperplane.

Method Detail

buildNewback to summary
public Region<S> buildNew(BSPTree<S> newTree)

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
newTree:BSPTree<S>

inside/outside BSP tree representing the new region

Returns:Region<S>

the built region

checkPointback to summary
public Region.Location checkPoint(final Point<S> point)

Check a point with respect to the region.

Parameters
point:Point<S>

point to check

Returns:Region.Location

a code representing the point status: either Location#INSIDE, Location#OUTSIDE or Location#BOUNDARY

containsback to summary
public boolean contains(final Region<S> region)

Check if the instance entirely contains another region.

Parameters
region:Region<S>

region to check against the instance

Returns:boolean

true if the instance contains the specified tree

copySelfback to summary
public Region<S> copySelf()

Copy the instance.

The instance created is completely independant of the original one. A deep copy is used, none of the underlying objects are shared (except for the underlying tree Boolean attributes and immutable objects).

Returns:Region<S>

a new region, copy of the instance

getBarycenterback to summary
public Point<S> getBarycenter()

Get the barycenter of the instance.

Returns:Point<S>

an object representing the barycenter

getBoundarySizeback to summary
public double getBoundarySize()

Get the size of the boundary.

Returns:double

the size of the boundary (this is 0 in 1D, a length in 2D, an area in 3D ...)

getSizeback to summary
public double getSize()

Get the size of the instance.

Returns:double

the size of the instance (this is a length in 1D, an area in 2D, a volume in 3D ...)

getTreeback to summary
public BSPTree<S> getTree(final boolean includeBoundaryAttributes)

Get the underlying BSP tree.

Regions are represented by an underlying inside/outside BSP tree whose leaf attributes are Boolean instances representing inside leaf cells if the attribute value is true and outside leaf cells if the attribute is false. These leaf attributes are always present and guaranteed to be non null.

In addition to the leaf attributes, the internal nodes which correspond to cells split by cut sub-hyperplanes may contain BoundaryAttribute objects representing the parts of the corresponding cut sub-hyperplane that belong to the boundary. When the boundary attributes have been computed, all internal nodes are guaranteed to have non-null attributes, however some BoundaryAttribute instances may have their getPlusInside and getPlusOutside methods both returning null if the corresponding cut sub-hyperplane does not have any parts belonging to the boundary.

Since computing the boundary is not always required and can be time-consuming for large trees, these internal nodes attributes are computed using lazy evaluation only when required by setting the includeBoundaryAttributes argument to true. Once computed, these attributes remain in the tree, which implies that in this case, further calls to the method for the same region will always include these attributes regardless of the value of the includeBoundaryAttributes argument.

Parameters
includeBoundaryAttributes:boolean

if true, the boundary attributes at internal nodes are guaranteed to be included (they may be included even if the argument is false, if they have already been computed due to a previous call)

Returns:BSPTree<S>

underlying BSP tree

See Also
BoundaryAttribute
intersectionback to summary
public SubHyperplane<S> intersection(final SubHyperplane<S> sub)

Get the parts of a sub-hyperplane that are contained in the region.

The parts of the sub-hyperplane that belong to the boundary are not included in the resulting parts.

Parameters
sub:SubHyperplane<S>

sub-hyperplane traversing the region

Returns:SubHyperplane<S>

filtered sub-hyperplane

isEmptyback to summary
public boolean isEmpty()

Check if the instance is empty.

Returns:boolean

true if the instance is empty

isEmptyback to summary
public boolean isEmpty(final BSPTree<S> node)

Check if the sub-tree starting at a given node is empty.

Parameters
node:BSPTree<S>

root node of the sub-tree (must have Region tree semantics, i.e. the leaf nodes must have Boolean attributes representing an inside/outside property)

Returns:boolean

true if the sub-tree starting at the given node is empty

isFullback to summary
public boolean isFull()

Check if the instance covers the full space.

Returns:boolean

true if the instance covers the full space

isFullback to summary
public boolean isFull(final BSPTree<S> node)

Check if the sub-tree starting at a given node covers the full space.

Parameters
node:BSPTree<S>

root node of the sub-tree (must have Region tree semantics, i.e. the leaf nodes must have Boolean attributes representing an inside/outside property)

Returns:boolean

true if the sub-tree starting at the given node covers the full space

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

Project a point on the boundary of the region.

Parameters
point:Point<S>

point to check

Returns:BoundaryProjection<S>

projection of the point on the boundary

Since
3.3
sideback to summary
public Side side(final Hyperplane<S> hyperplane)

Deprecated

as of 3.6, this method which was only intended for internal use is not used anymore

Compute the relative position of the instance with respect to an hyperplane.

Parameters
hyperplane:Hyperplane<S>

reference hyperplane

Returns:Side

one of Side.PLUS, Side.MINUS, Side.BOTH or Side.HYPER (the latter result can occur only if the tree contains only one cut hyperplane)

Annotations
@Deprecated
org.apache.commons.math3.geometry.partitioning back to summary

public final Enum Region.Location

extends Enum<Region.Location>
Class Inheritance

Enumerate for the location of a point with respect to the region.

Field Summary

Modifier and TypeField and Description
public static final Region.Location
BOUNDARY

Code for points on the partition boundary.

public static final Region.Location
INSIDE

Code for points inside the partition.

public static final Region.Location
OUTSIDE

Code for points outside of the partition.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Region.Location
public static Region.Location[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BOUNDARYback to summary
public static final Region.Location BOUNDARY

Code for points on the partition boundary.

INSIDEback to summary
public static final Region.Location INSIDE

Code for points inside the partition.

OUTSIDEback to summary
public static final Region.Location OUTSIDE

Code for points outside of the partition.

Constructor Detail

Locationback to summary
private Location()

Method Detail

valueOfback to summary
public static Region.Location valueOf(String name)
valuesback to summary
public static Region.Location[] values()