Crates.io | delatin |
lib.rs | delatin |
version | 0.2.1 |
source | src |
created_at | 2024-09-24 06:45:00.172444 |
updated_at | 2024-09-25 13:05:08.85556 |
description | Fast TIN generation using Delaunay triangulation. |
homepage | |
repository | https://github.com/pokhanto/delatin-rs |
max_upload_size | |
id | 1384838 |
size | 34,012 |
Simple and fast TIN generation library, written in Rust. Uses Delaunay triangulation.
Delatin is a port of Volodymyr Agafonkin's delatin (JavaScript) and Michael Fogleman's hmm (C++), which is in turn based on the paper Fast Polygonal Approximation of Terrains and Height Fields (1995) by Michael Garland and Paul Heckbert.
use delatin::{triangulate, Error};
let heights = vec![100.1, 123.4, 111.5, 121.4];
let width = 2;
let height = 2;
let max_error = Error(1.0);
// points `Vec<(usize, usize)>`: A vector containing all the vertices of the triangulated mesh. Each point corresponds to heights vector index.
// triangles `Vec<(usize, usize, usize)>`: A vector containing all the triangles of the mesh, each defined by indices into the `points`.
let (points, triangles) = triangulate(&heights, width, height, max_error)?;
cargo add delatin
Align your data in plot/src/main.rs and run:
cargo run --bin plot
cargo run --bin test --release