
FRAME_TRANSFORM
. This
enumerate must be passed as an argument to the few methods that depend
on an interpretation of the semantics of the angle/axis. The value
<code>VECTOR_OPERATOR corresponds to rotations that are
considered to move vectors within a fixed frame. The value
<code>FRAME_TRANSFORM corresponds to rotations that are
considered to represent frame rotations, so fixed vectors coordinates
change as their reference frame changes.
</p>
<p>
These examples show that a rotation means what the user wants it to
mean, so this class does not push the user towards one specific
definition and hence does not provide methods like
<code>projectVectorIntoDestinationFrame or
<code>computeTransformedDirection. It provides simpler and more
generic methods: <code>applyTo(Vector3D) and
<code>applyInverseTo(Vector3D).
</p>
<p>
Since a rotation is basically a vectorial operator, several
rotations can be composed together and the composite operation
<code>r = r_{1} o r_{2} (which means that for each
vector <code>u, r(u) = r_{1}(r_{2}(u))
)
is also a rotation. Hence we can consider that in addition to vectors, a
rotation can be applied to other rotations as well (or to itself). With our
previous notations, we would say we can apply <code>r_{1} to
<code>r_{2} and the result we get is r =
r<sub>1 o r_{2}
. For this purpose, the class
provides the methods: <code>compose(Rotation, RotationConvention) and
<code>composeInverse(Rotation, RotationConvention). There are also
shortcuts <code>applyTo(Rotation) which is equivalent to
<code>compose(Rotation, RotationConvention.VECTOR_OPERATOR) and
<code>applyInverseTo(Rotation) which is equivalent to
<code>composeInverse(Rotation, RotationConvention.VECTOR_OPERATOR).
</p>
</subsection>
<subsection name="11.3 nSphere" href="sphere">
<p>
The Apache Commons Math library provides a few classes dealing with geometry
on the 1sphere (i.e. the one dimensional circle corresponding to the boundary of
a twodimensional disc) and the 2sphere (i.e. the two dimensional sphere surface
corresponding to the boundary of a threedimensional ball). The main classes in
this package correspond to the region explained above, i.e.
<a href="../apidocs/org/apache/commons/math3/geometry/spherical/oned/ArcsSet.html">ArcsSet
and <a href="../apidocs/org/apache/commons/math3/geometry/spherical/twod/SphericalPolygonsSet.html">SphericalPolygonsSet.
</p>
</subsection>
<subsection name="11.4 Binary Space Partitioning" href="partitioning">
<p>
<a href="../apidocs/org/apache/commons/math3/geometry/partitioning/BSPTree.html">
BSP trees</a> are an efficient way to represent space partitions and
to associate attributes with each cell. Each node in a BSP tree
represents a convex region which is partitioned in two convex
subregions at each side of a cut hyperplane. The root tree
contains the complete space.
</p>
<p>
The main use of such partitions is to use a boolean attribute to
define an inside/outside property, hence representing arbitrary
polytopes (line segments in 1D, polygons in 2D and polyhedrons in
3D) and to operate on them. This is how the regions explained above in the Euclidean
and Sphere spaces are implemented. The partitioning package provides the engine to do the
computation, but not the dimensionspecific implementations. The
various interfaces in this package (hyperplane, subhyperplane, embedding,
and even region) are therefore not considered to be reusable public
interface, they are private interface. They may change and users are not expected to
rely directly on them. What users can rely on is the BSP tree class itself, and the
spacespecific implementations of the interfaces (i.e. Plane in 3D as the implementation
of hyperplane, or S2Point on the 2Sphere as the implementation of Point).
</p>
<p>
Another example of BST tree use would be to represent Voronoi tesselations, the
attribute of each cell holding the defining point of the cell. This is not
available yet.
</p>
<p>
The applicationdefined attributes are shared among copied
instances and propagated to split parts. These attributes are not
used by the BSPtree algorithms themselves, so the application can
use them for any purpose. Since the tree visiting method holds
internal and leaf nodes differently, it is possible to use
different classes for internal nodes attributes and leaf nodes
attributes. This should be used with care, though, because if the
tree is modified in any way after attributes have been set, some
internal nodes may become leaf nodes and some leaf nodes may become
internal nodes.
</p>
</subsection>
<subsection name="11.5 Regions">
<p>
The regions in all Euclidean and spherical spaces are based on BSPtree using a <code>Boolean
attribute in the leaf cells representing the inside status of the corresponding cell
(true for inside cells, false for outside cells). They all need a <code>tolerance setting that
is either provided at construction when the region is built from scratch or inherited from the input
regions when a region is build by set operations applied to other regions. This setting is used when
the region itself will be used later in another set operation or when points are tested against the
region to compute inside/outside/on boundary status. This tolerance is the <em>thickness
of the hyperplane. Points closer than this value to a boundary hyperplane will be considered
<em>on boundary. There are no default values anymore for this setting (there was one when
BSPtree support was introduced, but it created more problems than it solved, so it has been intentionally
removed). Setting this tolerance really depends on the expected values for the various coordinates. If for
example the region is used to model a geological structure with a scale of a few thousand meters, the expected
coordinates order of magnitude will be about 10<sup>3 and the tolerance could be set to 10^{7}
(i.e. 0.1 micrometer) or above. If very thin triangles or nearly parallel lines occur, it may be safer to use
a larger value like 10<sup>3 for example. Of course if the BSPtree is used to model a crystal at
atomic level with coordinates of the order of magnitude about 10<sup>9 the tolerance should be
drastically reduced (perhaps down to 10<sup>20 or so).
</p>
<p>
The recommended way to build regions is to start from basic shapes built from their boundary representation
and to use the set operations to combine these basic shapes into more complex shapes. The basic shapes
that can be constructed from boundary representations must have a closed boundary and be in one part
without holes. Regions in several nonconnected parts or with holes must be built by building the parts
beforehand and combining them. All regions (<code>IntervalsSet, PolygonsSet
,
<code>PolyhedronsSet, ArcsSet
, SphericalPolygonsSet
) provide a dedicated
constructor using only the mandatory tolerance distance without any other parameters that always create
the region covering the full space. The empty region case, can be built by building first the full space
region and applying the <code>RegionFactory.getComplement() method to it to get the corresponding
empty region, it can also be built directly for a onecell BSPtree as explained below.
</p>
<p>
Another way to build regions is to create directly the underlying BSPtree. All regions (<code>IntervalsSet,
<code>PolygonsSet, PolyhedronsSet
, ArcsSet
, SphericalPolygonsSet
)
provide a dedicated constructor that accepts a BSPtree and a tolerance. This way to build regions should be
reserved to dimple cases like the full space, the empty space of regions with only one or two cut hyperplances.
It is not recommended in the general case and is considered expert use. The leaf nodes of the BSPtree
<em>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 <code>Boolean.TRUE and Boolean.FALSE
. Using
this method, one way to build directly an empty region without complementing the full region is as follows
(note the tolerance parameter which must be present even for the empty region):
</p>
<source>
PolygonsSet empty = new PolygonsSet(new BSPTree<Euclidean2D>(false), tolerance);
</source>
<p>
In the Euclidean 3D case, the <a href="../apidocs/org/apache/commons/math3/geometry/euclidean/threed/PolyhedronsSet.html">PolyhedronsSet
class has another specific constructor to build regions from vertices and facets. The signature of this
constructor is:
</p>
<source>
PolyhedronsSet(List<Vector3D> vertices, List<int[]> facets, double tolerance);
</source>
<p>
The vertices list contains all the vertices of the polyhedrons, the facets list defines the facets,
as an indirection in the vertices list. Each facet is a short integer array and each element in a
facet array is the index of one vertex in the list. So in our cube example, the vertices list would
contain 8 points corresponding to the cube vertices, the facets list would contain 6 facets (the sides
of the cube) and each facet would contain 4 integers corresponding to the indices of the 4 vertices
defining one side. Of course, each vertex would be referenced once in three different facets.
</p>
<p>
Beware that despite some basic consistency checks are performed in the constructor, not everything
is checked, so it remains under caller responsibility to ensure the vertices and facets are consistent
and properly define a polyhedrons set. One particular trick is that when defining a facet, the vertices
<em>must be provided as walking the polygons boundary in trigonometric order (i.e.
counterclockwise) as seen from the *external* side of the facet. The reason for this is that the walking
order does define the orientation of the inside and outside parts, so walking the boundary on the wrong
order would reverse the facet and the polyhedrons would not be the one you intended to define. Coming
back to our cube example, a logical orientation of the facets would define the polyhedrons as the finite
volume within the cube to be the inside and the infinite space surrounding the cube as the outside, but
reversing all facets would also define a perfectly well behaved polyhedrons which would have the infinite
space surrounding the cube as its inside and the finite volume within the cube as its outside!
</p>
<p>
If one wants to further look at how it works, there is a test parser for PLY file formats in the unit tests
section of the library and some basic ply files for a simple geometric shape (the N pentomino) in the test
resources. This parser uses the constructor defined above as the PLY file format uses vertices and facets
to represent 3D shapes.
</p>
</subsection>
</section>
</body>
</document>
Here is a short list of links related to this Java geometry.xml source code file:

Java example source code file (geometry.xml)
The geometry.xml Java example source code<?xml version="1.0"?> <! Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. > <?xmlstylesheet type="text/xsl" href="./xdoc.xsl"?> <document url="geometry.html"> <properties> <title>The Commons Math User Guide  Geometry </properties> <body> <section name="11 Geometry"> <subsection name="11.1 Overview" href="overview"> <p> The geometry package provides classes useful for many physical simulations in Euclidean spaces, like vectors and rotations in 3D, as well as on the sphere. It also provides a general implementation of Binary Space Partitioning Trees (BSP trees). </p> <p> All supported type of spaces (Euclidean 3D, Euclidean 2D, Euclidean 1D, 2Sphere and 1Sphere) provide dedicated classes that represent complex regions of the space as shown in the following table: </p> <p> <table border="1" align="center"> <tr BGCOLOR="#CCCCFF">  Regions  
Space  Region  
Euclidean 1D  IntervalsSet  
Euclidean 2D  PolygonsSet  
Euclidean 3D  PolyhedronsSet  
1Sphere  ArcsSet  
2Sphere  SphericalPolygonsSet 
Copyright 19982019 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.