cleanup point transform code

This commit is contained in:
Henry Schimke
2023-03-08 12:46:52 -06:00
parent 2b7d053646
commit 717b74fd99
10 changed files with 190 additions and 158 deletions

View File

@@ -10,8 +10,8 @@ impl Quadrilateral {
// using Point = T;
#[allow(dead_code)]
pub fn new(tl:Point, tr: Point, br: Point, bl: Point) -> Self {
Self([tl,tr,br,bl])
pub fn new(tl: Point, tr: Point, br: Point, bl: Point) -> Self {
Self([tl, tr, br, bl])
}
// pub fn with_f32( tl:f32, tr:f32, br:f32, bl:f32) -> Self {
// Self([tl, tr,br, bl ])
@@ -124,11 +124,11 @@ impl Quadrilateral {
let d2 = self.0[i] - self.0[(i + 1) % N];
let cp = d1.cross(d2);
m = if m.abs() > cp { cp } else { m.abs() };
// m = if m.abs() > cp { cp } else { m.abs() };
M = if M.abs() > cp { M.abs() } else { cp };
// m = std::cmp::min((m).abs(), cp);
// M = std::cmp::max((M).abs(), cp);
// M = if M.abs() > cp { M.abs() } else { cp };
m = f32::min((m).abs(), cp);
M = f32::max((M).abs(), cp);
if i == 0 {
sign = cp > 0.0;
@@ -214,4 +214,4 @@ impl Default for Quadrilateral {
fn default() -> Self {
Self([Point { x: 0.0, y: 0.0 }; 4])
}
}
}