Skip to content

Commit

Permalink
Fix rustdoc error in Triangle. (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys authored Jul 20, 2024
1 parent 7c8faee commit 01933c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/shape/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,13 @@ impl Shape for Triangle {

fn feature_normal_at_point(
&self,
feature: FeatureId,
_feature: FeatureId,
_point: &Point<Real>,
) -> Option<Unit<Vector<Real>>> {
self.feature_normal(feature)
#[cfg(feature = "dim2")]
return None;
#[cfg(feature = "dim3")]
return self.feature_normal(_feature);
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/shape/triangle.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
//! Definition of the triangle shape.
use crate::math::{Isometry, Point, Real, Vector};
use crate::shape::{FeatureId, SupportMap};
use crate::shape::SupportMap;
use crate::shape::{PolygonalFeature, Segment};
use crate::utils;

use na::{self, ComplexField, Unit};
use num::Zero;
#[cfg(feature = "dim3")]
use std::f64;
use std::mem;

#[cfg(feature = "dim3")]
use {crate::shape::FeatureId, std::f64};

#[cfg(feature = "dim2")]
use crate::shape::PackedFeatureId;

Expand Down Expand Up @@ -138,6 +139,7 @@ impl Triangle {
/// The normal points such that it is collinear to `AB × AC` (where `×` denotes the cross
/// product).
#[inline]
#[cfg(feature = "dim3")]
pub fn normal(&self) -> Option<Unit<Vector<Real>>> {
Unit::try_new(self.scaled_normal(), crate::math::DEFAULT_EPSILON)
}
Expand Down Expand Up @@ -230,10 +232,12 @@ impl Triangle {
///
/// The vector points such that it is collinear to `AB × AC` (where `×` denotes the cross
/// product).
///
/// Note that on thin triangles the calculated normals can suffer from numerical issues.
/// For a more robust (but more computationally expensive) normal calculation, see
/// [`Triangle::robust_scaled_normal`].
#[inline]
#[cfg(feature = "dim3")]
pub fn scaled_normal(&self) -> Vector<Real> {
let ab = self.b - self.a;
let ac = self.c - self.a;
Expand Down Expand Up @@ -535,6 +539,7 @@ impl Triangle {
}

/// The normal of the given feature of this shape.
#[cfg(feature = "dim3")]
pub fn feature_normal(&self, _: FeatureId) -> Option<Unit<Vector<Real>>> {
self.normal()
}
Expand Down

0 comments on commit 01933c8

Please sign in to comment.