A modular three-dimensional (3D) Euclidean geometry Java library.
There are two main implementations distinguished by the type of numbers used for calculations and to represent coordinates:
- Coordinates and calculations using Java double precision primitive numbers.
- Coordinates and calculations using a combination of BigRational and Math_BigRationalSqrt numbers.
Vectors are defined using cartesian coordinates. The orthogonal X, Y and Z axes meet at the origin - a point <x,y,z> where x=y=z=0.
Geometry calculation with Java double precision primitives typically use a small tollerance value (epsilon) to evaluate whether two vectors are the same. The accuracy of this geometry varies due to the nature of floating point arithmetic.
Geometry calculation with BigRational and Math_BigRationalSqrt can be done with a more arbitrarily specified precision based on the Order of Magnitude (OOM) of the precision wanted. Math_BigRationalSqrt allow for coordinate values at precise non-rational square roots e.g.
The coordinate systems are "right handed", so: if X increases to the right of this page; and, Y increases towards the top of this page, then Z increases out from the page, (see Orientation and the note on the choice of right over left handedness for details of why this handedness was chosen.
I envisaged using this library to develop a Digital Twin Earth.
The development of the library is aided by ccg-r3d - a rendering library for visualising 3D spatial geometry.
- These are in the uk.ac.leeds.ccg.v3d.geometry.light and uk.ac.leeds.ccg.v3d.geometry.d.light packages. These use V3D_V or V3D_VDouble as vectors which can be used to represent points.
- V3D_VLine and V3D_VLineDouble representing finite straight lines and comprise two vectors.
- V3D_VTriangle and V3D_VTriangleDouble represent triangles as three finite lines which are the edges of the triangle.
- V3D_VTetrahedron and V3D_VTetrahedronDouble represent solid tetrahedra with 4 trianglular faces.
- These are in the uk.ac.leeds.ccg.v3d.geometry and uk.ac.leeds.ccg.v3d.geometry.d packages.
- V3D_Vector and V3D_VectorDouble are the vector classes.
- V3D_Point and V3D_PointDouble are for points. A vector called rel gives the location of the point relative to a translated origin which is given by another vector called offset.
- V3D_Line and V3D_LineDouble are for infinite lines that intersect a given point and are also defined by a given non zero vector.
- V3D_Ray and V3D_RayDouble are for rays that extends from a point in the direction given by a non-zero vector.
- V3D_Plane and V3D_PlaneDouble are for infinite planes. A plane is defined by a point and a normal vector and can also be constructed using 3 points that are not collinear or coincident. (See also plane geometry).
- V3D_AABB and V3D_Double are for Axis Aligned Bounding Boxes. The dimensions of AABB can collapse from a box to a rectangle to a line to a point. AABB are not used to represent shapes, but they are constructed for shapes to speed up algorithms.
- V3D_LineSegment and V3D_LineSegmentDouble are for representing single continuous finite lines between two points. Like points these are a finite geometry, but not a shape.
- V3D_Triangle and V3D_TriangleDouble are for triangles - shapes with area and perimeter.
- V3D_Tetrahedron and V3D_TetrahedronDouble represent tetrahedra - shapes with area, perimeter and volume.
- V3D_Rectangle and V3D_TetrahedronDouble represent rectangle - shapes with area and perimeter.
- An initial implementation resulted in visualisations of the Utah Teapot. The library has since been redeveloped and the rendering of the Utah Tepot no longer works. This wants fixing...
- 3D convex hull
- 3D Shape with external holes.
- 3D Shape with internal holes.
- Create a model of Earth and images in 3D revealing land/ice and water.
arbitrary precision geometrical functionality...
- Intersections -- It would be useful to be able to distinguish between geometries that touch at a point, along a line or line_segment or over an area; and those that overlap (all or part of) another geometry. -- Geometry intersections calculations for triangular or simpler geometries are supported. -- Implementations of methods to calculate the intersection between tetrahedrons and simpler geometries are wanted.
- Distances -- There are methods for calculating the minimum distance between geometries including triangles and simpler geometries. -- Implementations of methods to calulate distances between tetrahedrons and simpler geometries are wanted.
- New geometries are wanted for surfaces.
- Surface Areas, Perimeters and Volumes -- For some shapes there are implementations of methods for calculating these.
- Thanks for thinking about this.
- If this is to form into a collaborative project, it could do with a Code of Conduct and Contributor Guidelines based on something like this: Open Source Guide
- APACHE LICENSE, VERSION 2.0
- Other licences are possible!
- The University of Leeds has indirectly supported this work by employing me over the years and encouraging me to develop the skills necessary to produce this library.
- Thank you Eric for the BigMath library.
For a solar system model or a model of Earth, it is probably best to set the origin at the centre of mass (CoM).
Handedness or chirality concerns the assignment of coordinate axes/directions. The choice of left-handed or right-handed is somewhat arbitrary, but this library uses a right-handed system as it is suggested this is more commonly used in geography and physics (video). Originally the library began using a left-handed system based on the logic of vertical viewing screens, graphs and zooming in and out by the viewer moving closer and further away from the screen.
- Spherical and ecliptic coordinate systems and Discrete_global_grid systems are being used for some applications.
- Geographical projections are commonly used to represent part or all of the surface of Earth as plan view maps. Equirectangular_projections have: the Y Axis used for lines of latitude, with zero on the equator, increasing to the North pole, and decreasing to the South pole; the X Axis used for lines of longitude, typically with zero on the prime meridian, increasing to the East, and decreasing to the West; and the Z axis represents height (often a measure of a surface height like above or below mean sea-level. The choice of the meridian is arbitrary. For a 3D coordinate system with the origin at the centre of mass of Earth, the Y axis could match some aveage of that axis of Earth's rotation), the X axis could draw out from some nominal centre of Earth towards the intersection of the equator and the Greenwich/Prime meridian with the Z axis orthogonal to the others and in a right handed way...
- Apache Commons Geometry (see also: Apache Commons Geometry GitHub Repository)
- Java
- Uses both floating point and large rational numbers for coordinates.
- Geometric Tools Library
- C++.
- Uses both floating point and large rational numbers for coordinates.
- VTK-m - README - VTK-m GitHub Mirror
- C/C++.
- Uses floating point for coordinates.
- VisIt
- Open Source, interactive, scalable, visualization, animation and analysis tool.
- Languages: C 75.8%, C++ 12.8%, Python 3.8%, Java 3.0%
- Github repository
- Fides
- Fides enables complex scientific workflows to seamlessly integrate simulation and visualization. This is done by providing a data model in JSON that describes the mesh and fields in the data to be read. Using this data model, Fides maps ADIOS2 data arrays (from files or streams) to VTK-m datasets, enabling visualization of the data using shared- and distributed-memory parallel algorithms.
- Can be used with Paraview
- ParaView
- Open source post-processing visualization engine.
- Uses VTK - an open-source, freely available software system for 3D computer graphics, modeling, image processing, volume rendering, scientific visualization, and 2D plotting - VTK GitHub Mirror