blob: 3edcb1d59974c1c3af5b6373215c88c16f5076ff [file] [log] [blame]
<?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/LICENSE-2.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.
-->
<document>
<properties>
<title>Commons Geometry</title>
</properties>
<body>
<section name="Apache Commons Geometry" href="summary">
<p>
Commons Geometry provides types and utilities for geometric processing. Key features include
</p>
<ul>
<li>Support for Euclidean space in 1, 2, and 3 dimensions</li>
<li>Support for spherical space in 1 and 2 dimensions</li>
<li>Support for geometric elements of infinite size</li>
<li>Support for boolean operations on regions (union, intersection, difference, xor)</li>
<li>Single external dependency (<a href="https://commons.apache.org/proper/commons-numbers/"
>commons-numbers</a>)</li>
</ul>
<p>The code below gives a small sample of the API by computing the intersection of cube with a rotated
version of itself. See the <a href="userguide/index.html">user guide</a> for more details.
</p>
<source class="prettyprint">// construct a precision context to handle floating-point comparisons
DoublePrecisionContext precision = new EpsilonDoublePrecisionContext(1e-6);
// create a binary space partitioning tree representing the unit cube
// centered on the origin
RegionBSPTree3D region = Boundaries3D.rect(
Vector3D.of(-0.5, -0.5, -0.5), Vector3D.of(0.5, 0.5, 0.5), precision)
.toTree();
// create a rotated copy of the region
Transform3D rotation = QuaternionRotation.fromAxisAngle(Vector3D.Unit.PLUS_Z, 0.25 * Math.PI);
RegionBSPTree3D copy = region.copy();
copy.transform(rotation);
// compute the intersection of the regions, storing the result back into the caller
// (the result could also have been placed into a third region)
region.intersection(copy);
// compute some properties of the intersection region
double size = region.getSize(); // 0.8284271247461903
Vector3D center = region.getBarycenter(); // (0, 0, 0)
</source>
</section>
<section name="Download Apache Commons Geometry">
<subsection name="Releases">
<p>
Download the
<a href="https://commons.apache.org/geometry/download_geometry.cgi">
latest release</a> of Apache Commons Geometry.
</p>
</subsection>
</section>
</body>
</document>