src/site/xdoc/index.xml (65 lines of code) (raw):

<?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 is a general-purpose Java library for geometric processing. The primary goal of the project is to provide a set of geometric types and utilities that are <ul> <li>mathematically correct,</li> <li>numerically accurate,</li> <li>easy to use, and</li> <li>performant.</li> </ul> Key features of the library include <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>Support for reading and writing common geometric data formats, such as STL and OBJ</li> <li>Single external dependency (<a href="https://commons.apache.org/proper/commons-numbers/" >commons-numbers</a>)</li> </ul> </p> <p>The code below gives a small sample of the API by computing the difference of a cube and an approximation of a sphere and writing the result to a file using the <a href="https://en.wikipedia.org/wiki/Wavefront_.obj_file">OBJ</a> data format. See the <a href="userguide/index.html">user guide</a> for more details. </p> <source class="prettyprint"> // construct a precision instance to handle floating-point comparisons Precision.DoubleEquivalence precision = Precision.doubleEquivalenceOfEpsilon(1e-6); // create a BSP tree representing the unit cube RegionBSPTree3D tree = Parallelepiped.unitCube(precision).toTree(); // create a sphere centered on the origin Sphere sphere = Sphere.from(Vector3D.ZERO, 0.65, precision); // subtract a BSP tree approximation of the sphere containing 512 facets // from the cube, modifying the cube tree in place tree.difference(sphere.toTree(3)); // compute some properties of the resulting region double size = tree.getSize(); // 0.11509505362599505 Vector3D centroid = tree.getCentroid(); // (0, 0, 0) // convert to a triangle mesh TriangleMesh mesh = tree.toTriangleMesh(precision); // save as an OBJ file IO3D.write(mesh, Paths.get("target/cube-minus-sphere.obj")); </source> <p>Below is an image of the triangle mesh rendered with <a href="https://www.blender.org/" target="_blank">Blender</a>. </p> <img src="images/cube-minus-sphere.png" /> </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>