|
1 | 1 | //! Definition of the triangle shape. |
2 | 2 |
|
3 | 3 | use crate::math::{Isometry, Point, Real, Vector}; |
4 | | -use crate::shape::{FeatureId, SupportMap}; |
| 4 | +use crate::shape::SupportMap; |
5 | 5 | use crate::shape::{PolygonalFeature, Segment}; |
6 | 6 | use crate::utils; |
7 | 7 |
|
8 | 8 | use na::{self, ComplexField, Unit}; |
9 | 9 | use num::Zero; |
10 | | -#[cfg(feature = "dim3")] |
11 | | -use std::f64; |
12 | 10 | use std::mem; |
13 | 11 |
|
| 12 | +#[cfg(feature = "dim3")] |
| 13 | +use {crate::shape::FeatureId, std::f64}; |
| 14 | + |
14 | 15 | #[cfg(feature = "dim2")] |
15 | 16 | use crate::shape::PackedFeatureId; |
16 | 17 |
|
@@ -138,6 +139,7 @@ impl Triangle { |
138 | 139 | /// The normal points such that it is collinear to `AB × AC` (where `×` denotes the cross |
139 | 140 | /// product). |
140 | 141 | #[inline] |
| 142 | + #[cfg(feature = "dim3")] |
141 | 143 | pub fn normal(&self) -> Option<Unit<Vector<Real>>> { |
142 | 144 | Unit::try_new(self.scaled_normal(), crate::math::DEFAULT_EPSILON) |
143 | 145 | } |
@@ -230,10 +232,12 @@ impl Triangle { |
230 | 232 | /// |
231 | 233 | /// The vector points such that it is collinear to `AB × AC` (where `×` denotes the cross |
232 | 234 | /// product). |
| 235 | + /// |
233 | 236 | /// Note that on thin triangles the calculated normals can suffer from numerical issues. |
234 | 237 | /// For a more robust (but more computationally expensive) normal calculation, see |
235 | 238 | /// [`Triangle::robust_scaled_normal`]. |
236 | 239 | #[inline] |
| 240 | + #[cfg(feature = "dim3")] |
237 | 241 | pub fn scaled_normal(&self) -> Vector<Real> { |
238 | 242 | let ab = self.b - self.a; |
239 | 243 | let ac = self.c - self.a; |
@@ -535,6 +539,7 @@ impl Triangle { |
535 | 539 | } |
536 | 540 |
|
537 | 541 | /// The normal of the given feature of this shape. |
| 542 | + #[cfg(feature = "dim3")] |
538 | 543 | pub fn feature_normal(&self, _: FeatureId) -> Option<Unit<Vector<Real>>> { |
539 | 544 | self.normal() |
540 | 545 | } |
|
0 commit comments