mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-16 05:06:11 +00:00
Fix Triangle<2>::winding_direction
For some reason, the Parry function gave a wrong result.
This commit is contained in:
parent
58329a83f6
commit
cd1844fc4f
@ -1,4 +1,4 @@
|
||||
use parry2d_f64::utils::point_in_triangle::{corner_direction, Orientation};
|
||||
use parry2d_f64::utils::point_in_triangle::Orientation;
|
||||
use parry3d_f64::query::{Ray, RayCast as _};
|
||||
|
||||
use crate::Vector;
|
||||
@ -59,8 +59,17 @@ impl<const D: usize> Triangle<D> {
|
||||
impl Triangle<2> {
|
||||
/// Returns the direction of the line through the points of the triangle.
|
||||
pub fn winding_direction(&self) -> Winding {
|
||||
let [v0, v1, v2] = self.points.map(|point| point.to_na());
|
||||
corner_direction(&v0, &v1, &v2).into()
|
||||
let [pa, pb, pc] = self.points.map(|point| point.into());
|
||||
let orient2d = robust_predicates::orient2d(&pa, &pb, &pc);
|
||||
|
||||
if orient2d < 0. {
|
||||
return Winding::Cw;
|
||||
}
|
||||
if orient2d > 0. {
|
||||
return Winding::Ccw;
|
||||
}
|
||||
|
||||
unreachable!("not a triangle")
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user