diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-12 20:37:56 +0800 |
---|---|---|
committer | Jovansonlee Cesar <ivanceras@gmail.com> | 2021-07-12 20:37:56 +0800 |
commit | 039c74fefaab4c7226de57f258072fb6a5974722 (patch) | |
tree | 81c8d55990f7da6ea9c6398f247f767fce119845 /svgbob/src/util.rs | |
parent | d379b7fe9ae6fa79d553715329d638301600319f (diff) |
Initial migration from ncollide2d to parry2d
Diffstat (limited to 'svgbob/src/util.rs')
-rw-r--r-- | svgbob/src/util.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/svgbob/src/util.rs b/svgbob/src/util.rs index 4253c5f..499bf9f 100644 --- a/svgbob/src/util.rs +++ b/svgbob/src/util.rs @@ -1,4 +1,5 @@ use crate::Point; +use ncollide2d::shape::Triangle; use ncollide2d::{bounding_volume::AABB, math::Isometry, query::PointQuery}; use std::cmp::Ordering; @@ -27,7 +28,7 @@ pub fn ord(f1: f32, f2: f32) -> Ordering { /// clips a line to the bounding box of this whole grid /// and approximate each point to the closes intersection fn clip_line_internal( - aabb: &AABB<f32>, + aabb: &AABB, start: Point, end: Point, ) -> Option<(Point, Point)> { @@ -45,7 +46,7 @@ fn clip_line_internal( /// clip a line but do not extend the points pub fn clip_line( - aabb: &AABB<f32>, + aabb: &AABB, start: Point, end: Point, ) -> Option<(Point, Point)> { @@ -74,7 +75,8 @@ pub fn clip_line( /// the threshold are of 0.01 is used since /// lines may not be very aligned. pub fn is_collinear(a: &Point, b: &Point, c: &Point) -> bool { - ncollide2d::utils::triangle_area(a, b, c) < 0.01 + use std::ops::Deref; + Triangle::new(*a.deref(), *b.deref(), *c.deref()).area() < 0.01 } pub fn pad(v: f32) -> f32 { |