Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement feature_normal_at_point for trimesh #181

Merged
merged 8 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

## Unreleased

### Added

- `TriMesh` now implements `Shape::feature_normal_at_point` to retrieve the normal of a face, when passing a `FeatureId::Face`.

## v0.17.1

### Modified

- Improve convergence of epa algorithm in degenerate configurations.
- Fix bug in the esh/mesh intersection algorithm that didn’t properly take mesh transforms into account.
- Fix bug in the mesh/mesh intersection algorithm that didn’t properly take mesh transforms into account.

## v0.17.0

Expand Down
12 changes: 12 additions & 0 deletions src/shape/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,18 @@ impl Shape for TriMesh {
Real::frac_pi_4()
}

/// Gets the normal of the triangle represented by `feature`.
fn feature_normal_at_point(
&self,
_feature: FeatureId,
_point: &Point<Real>,
) -> Option<Unit<Vector<Real>>> {
#[cfg(feature = "dim2")]
return None;
#[cfg(feature = "dim3")]
return self.feature_normal(_feature);
}

#[cfg(feature = "std")]
fn as_composite_shape(&self) -> Option<&dyn SimdCompositeShape> {
Some(self as &dyn SimdCompositeShape)
Expand Down
11 changes: 11 additions & 0 deletions src/shape/trimesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,17 @@ impl TriMesh {
)
})
}

#[cfg(feature = "dim3")]
/// Gets the normal of the triangle represented by `feature`.
pub fn feature_normal(&self, feature: FeatureId) -> Option<Unit<Vector<Real>>> {
match feature {
FeatureId::Face(i) => self
.triangle(i % self.num_triangles() as u32)
.feature_normal(FeatureId::Face(0)),
_ => None,
}
}
}

impl TriMesh {
Expand Down