Crates.io | mesh-rand |
lib.rs | mesh-rand |
version | 0.1.0 |
source | src |
created_at | 2023-03-03 17:06:26.478298 |
updated_at | 2023-03-03 17:06:26.478298 |
description | provides methods of generating random points on the surface of 3d models. |
homepage | |
repository | https://github.com/samuelselleck/mesh-rand |
max_upload_size | |
id | 799878 |
size | 9,517 |
Rust library for generating random points on the surface of a mesh
use mesh_rand::{MeshSurface, SurfSample};
use rand::distributions::Distribution;
// Verticies and faces for a non-regular tetrahedron:
let verticies = [
[0.0, 0.0, 0.0],
[1.0, 0.0, 0.0],
[0.0, 1.0, 0.0],
[0.0, 0.0, 1.0],
];
let faces = [[1, 0, 2], [2, 0, 3], [0, 1, 3], [1, 2, 3]];
let mesh_dist = MeshSurface::new(&verticies, &faces)?;
let mut rng = rand::thread_rng();
let SurfSample { position, .. } = mesh_dist.sample(&mut rng);
println!("generated point on mesh at {position:?}");