Skip to content

Commit 01933c8

Browse files
Fix rustdoc error in Triangle. (#235)
1 parent 7c8faee commit 01933c8

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/shape/shape.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,10 +893,13 @@ impl Shape for Triangle {
893893

894894
fn feature_normal_at_point(
895895
&self,
896-
feature: FeatureId,
896+
_feature: FeatureId,
897897
_point: &Point<Real>,
898898
) -> Option<Unit<Vector<Real>>> {
899-
self.feature_normal(feature)
899+
#[cfg(feature = "dim2")]
900+
return None;
901+
#[cfg(feature = "dim3")]
902+
return self.feature_normal(_feature);
900903
}
901904
}
902905

src/shape/triangle.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
//! Definition of the triangle shape.
22
33
use crate::math::{Isometry, Point, Real, Vector};
4-
use crate::shape::{FeatureId, SupportMap};
4+
use crate::shape::SupportMap;
55
use crate::shape::{PolygonalFeature, Segment};
66
use crate::utils;
77

88
use na::{self, ComplexField, Unit};
99
use num::Zero;
10-
#[cfg(feature = "dim3")]
11-
use std::f64;
1210
use std::mem;
1311

12+
#[cfg(feature = "dim3")]
13+
use {crate::shape::FeatureId, std::f64};
14+
1415
#[cfg(feature = "dim2")]
1516
use crate::shape::PackedFeatureId;
1617

@@ -138,6 +139,7 @@ impl Triangle {
138139
/// The normal points such that it is collinear to `AB × AC` (where `×` denotes the cross
139140
/// product).
140141
#[inline]
142+
#[cfg(feature = "dim3")]
141143
pub fn normal(&self) -> Option<Unit<Vector<Real>>> {
142144
Unit::try_new(self.scaled_normal(), crate::math::DEFAULT_EPSILON)
143145
}
@@ -230,10 +232,12 @@ impl Triangle {
230232
///
231233
/// The vector points such that it is collinear to `AB × AC` (where `×` denotes the cross
232234
/// product).
235+
///
233236
/// Note that on thin triangles the calculated normals can suffer from numerical issues.
234237
/// For a more robust (but more computationally expensive) normal calculation, see
235238
/// [`Triangle::robust_scaled_normal`].
236239
#[inline]
240+
#[cfg(feature = "dim3")]
237241
pub fn scaled_normal(&self) -> Vector<Real> {
238242
let ab = self.b - self.a;
239243
let ac = self.c - self.a;
@@ -535,6 +539,7 @@ impl Triangle {
535539
}
536540

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

0 commit comments

Comments
 (0)