mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-25 20:02:34 +00:00
more generic point in result_point_util
This commit is contained in:
@@ -26,7 +26,7 @@ pub fn orderBestPatterns<T: Into<Point> + 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<T: Into<Point> + 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))
|
||||
}
|
||||
|
||||
@@ -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<T>, b: PointT<T>, c: PointT<T>) -> T {
|
||||
((c.x - b.x) * (a.y - b.y)) - ((c.y - b.y) * (a.x - b.x))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(i32, i32)> for Point {
|
||||
|
||||
Reference in New Issue
Block a user