From b50869833444e7deed311d0b3767867d8a86345b Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Thu, 4 May 2023 14:15:14 -0500 Subject: [PATCH] more generic point in result_point_util --- src/result_point_utils.rs | 9 +-------- src/rxing_result_point.rs | 7 +++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/result_point_utils.rs b/src/result_point_utils.rs index c8a4a33..17c9ccd 100644 --- a/src/result_point_utils.rs +++ b/src/result_point_utils.rs @@ -26,7 +26,7 @@ pub fn orderBestPatterns + Copy>(patterns: &mut [T; 3]) { // This asks whether BC x BA has a positive z component, which is the arrangement // we want for A, B, C. If it's negative, then we've got it flipped around and // should swap A and C. - if crossProductZ(pointA.into(), pointB.into(), pointC.into()) < 0.0 { + if Point::crossProductZ(pointA.into(), pointB.into(), pointC.into()) < 0.0 { std::mem::swap(&mut pointA, &mut pointC); } @@ -34,10 +34,3 @@ pub fn orderBestPatterns + Copy>(patterns: &mut [T; 3]) { patterns[1] = pointB; patterns[2] = pointC; } - -/** - * Returns the z component of the cross product between vectors BC and BA. - */ -fn crossProductZ(a: Point, b: Point, c: Point) -> f32 { - ((c.x - b.x) * (a.y - b.y)) - ((c.y - b.y) * (a.x - b.x)) -} diff --git a/src/rxing_result_point.rs b/src/rxing_result_point.rs index d0f14a7..b17fd01 100644 --- a/src/rxing_result_point.rs +++ b/src/rxing_result_point.rs @@ -365,6 +365,13 @@ where y: self.y.floor(), } } + + /** + * Returns the z component of the cross product between vectors BC and BA. + */ + pub fn crossProductZ(a: PointT, b: PointT, c: PointT) -> T { + ((c.x - b.x) * (a.y - b.y)) - ((c.y - b.y) * (a.x - b.x)) + } } impl From<(i32, i32)> for Point {