mesh_rand/lib.rs
1//! This crate provides methods of generating random points on the surface of 3d models.
2//!
3//! ```
4//! use mesh_rand::{MeshSurface, SurfSample};
5//! use rand::distributions::Distribution;
6//!
7//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
8//! // Verticies for a non-regular tetrahedron:
9//! let verticies = [
10//! [0.0, 0.0, 0.0],
11//! [1.0, 0.0, 0.0],
12//! [0.0, 1.0, 0.0],
13//! [0.0, 0.0, 1.0],
14//! ];
15//! // Faces, oriented to be pointing outwards:
16//! let faces = [[1, 0, 2], [2, 0, 3], [0, 1, 3], [1, 2, 3]];
17//! let mesh_dist = MeshSurface::new(&verticies, &faces)?;
18//! let mut rng = rand::thread_rng();
19//! let SurfSample { position, .. } = mesh_dist.sample(&mut rng);
20//! println!("generated point on mesh at {position:?}");
21//! # Ok(())
22//! # }
23//! ```
24mod meshsurface;
25mod vecmath;
26pub use meshsurface::MeshSurface;
27pub use meshsurface::SurfSample;