| Crates.io | geom3 |
| lib.rs | geom3 |
| version | 1.2.2 |
| created_at | 2025-03-09 19:42:05.069022+00 |
| updated_at | 2025-03-28 09:12:53.207553+00 |
| description | 3d geometry classes |
| homepage | https://github.com/Phornee/geom3 |
| repository | https://github.com/Phornee/geom3 |
| max_upload_size | |
| id | 1585763 |
| size | 27,955 |
geom3 is a rust library for dealing with 3D basic geometric calculations, such as Lines, Spheres, Planes or Triangles (including barycentric coordinates).
This low level library focuses only in the mathematical side of things, to be as flexible as possible: if you intend to use it for example for a raytracer, this library provides the mathematical base for it, but WONT provide specific concepts like "Rays", "Collisions", "UV coordinates", "Materials" of "Meshes". You can use this library and build your own specific classes for that.
The main focus of this package is performance. All formulas try to be optimal in terms of performance, using the most efficient algorithms i could find, and precalculating everything that is suitable to be extracted from the critical functions.
If you find something that could be optimized, please don“t hesitate to contact me.
You can create/operate with 3D geometric shapes, and calculate intersections, reflections, etc
It uses vector3 project for managing 3d vectors (https://docs.rs/crate/vector3/latest)
Make sure you have a project set up using cargo then:
cargo add geom3
Documentation with explanation of formulas in all functions
Performance profiling with 'Vector3' and 'List': Are there better options?.
geom3 uses the vectorial form of the line to calculate intersections. It will calculate only the lambda of each intersection.
let sphere = Sphere::new(&Vector3::new(0.0, 0.0, 0.0), 2.0);
let line = Line3::new(&Vector3::new(0.0, 0.0, 0.0), &Vector3::new(0.0, 0.0, 10.0));
let instersection: List::<f64> = sphere.intersects(&line);
for (_i, &lambda) in instersection.iter().enumerate() {
let point = line.calc_point(lambda);
}
This provides:
Line3.Please, take a look to the unittests for more examples