Skip to content

Commit

Permalink
v0.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
nobuyuki83 committed Feb 13, 2024
1 parent b0cf0b6 commit 7123c33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# del-geo

Utility library for geometry computation in Rust.
Rust 🦀 utility library for primitive (e.g., line, tri) geometry computation intended for computer graphics prototyping 🛠 and research 🧪.

Originally, the code is written in C++ in [DelFEM2](https://github.com/nobuyuki83/delfem2), then it was ported to Rust.
📔 See [the documentation generated from code](https://docs.rs/del-geo)

See [the documentation generated from code](https://docs.rs/del-geo)
> [!WARNING]
> **del-geo** is still in its initial development phase. Crates published to https://crates.io/crates/del-geo in the 0.1.x series do not obey SemVer and are unstable.
Originally, the code is written in C++ in [DelFEM2](https://github.com/nobuyuki83/delfem2), then it was ported to Rust.
8 changes: 6 additions & 2 deletions src/tri3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn clamp<T>(r0: T,r1: T,r2: T) -> (T,T,T)

// ----------------------

/// area of a 3D triangle (coordinates given by stack-allocated arrays)
pub fn area_<T>(
p0: &[T;3],
p1: &[T;3],
Expand All @@ -38,6 +39,7 @@ pub fn area_<T>(
vec3::squared_norm_(&na).sqrt() * 0.5_f64.as_()
}

/// normal vector of a 3D triangle (coordinates given by stack-allocated arrays)
pub fn normal_<T>(
vnorm: &mut [T;3],
v1: &[T;3],
Expand Down Expand Up @@ -91,7 +93,7 @@ pub fn area_and_unorm_<T>(
}


/// compute contangent for angles of a triangle
/// compute cotangents of the three angles of a triangle
pub fn cot_<T>(
p0: &[T;3],
p1: &[T;3],
Expand Down Expand Up @@ -142,6 +144,7 @@ pub fn emat_cotangent_laplacian<T>(
// ----------

/// Möller–Trumbore ray-triangle intersection algorithm
///
/// https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm
/// https://www.scratchapixel.com/lessons/3d-basic-rendering/ray-tracing-rendering-a-triangle/moller-trumbore-ray-triangle-intersection
pub fn ray_triangle_intersection_<T>(
Expand Down Expand Up @@ -188,7 +191,7 @@ pub fn height<T>(
a * 2.0.as_() / (p0 - p1).norm()
}


/// normal of a triangle
pub fn normal<T>(
p0: &nalgebra::Vector3::<T>,
p1: &nalgebra::Vector3::<T>,
Expand All @@ -198,6 +201,7 @@ pub fn normal<T>(
(p1 - p0).cross(&(p2 - p0))
}

/// unit normal of a triangle
pub fn unit_normal<T>(
p0: &nalgebra::Vector3::<T>,
p1: &nalgebra::Vector3::<T>,
Expand Down

0 comments on commit 7123c33

Please sign in to comment.