From bd6b7ff217dae9184399d93753be6d3b8d52066a Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 2 Sep 2024 15:01:04 -0700 Subject: [PATCH] move zeroes to fixed_wide --- src/lib.rs | 1 - src/zeroes.rs | 47 ----------------------------------------------- 2 files changed, 48 deletions(-) delete mode 100644 src/zeroes.rs diff --git a/src/lib.rs b/src/lib.rs index a5a0f17..c80e88a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,7 +5,6 @@ pub mod aabb; pub mod model; pub mod mouse; pub mod timer; -pub mod zeroes; pub mod integer; pub mod physics; pub mod updatable; diff --git a/src/zeroes.rs b/src/zeroes.rs deleted file mode 100644 index 5a16c57..0000000 --- a/src/zeroes.rs +++ /dev/null @@ -1,47 +0,0 @@ -//find roots of polynomials -use arrayvec::ArrayVec; -use std::cmp::Ordering; -use deferred_division::ratio::Ratio; -use fixed_wide::typenum::Unsigned; -use fixed_wide::fixed::Fixed; -use fixed_wide::wide::WideMul; - -#[inline] -pub fn zeroes2(a0:Fixed,a1:Fixed,a2:Fixed)->ArrayVec,Fixed>,2> - where - Fixed:WideMul, - as WideMul>::Output:std::ops::Mul, - as WideMul>::Output:std::ops::Sub<< as WideMul>::Output as std::ops::Mul>::Output> -{ - let a2pos=match a2.cmp(&Fixed::::ZERO){ - Ordering::Greater=>true, - Ordering::Equal=>return zeroes1(a0,a1), - Ordering::Less=>true, - }; - let radicand=a1.wide_mul(a1)-a2.wide_mul(a0)*4; - match radicand.cmp(&Fixed::::ZERO){ - Ordering::Greater=>{ - //start with f64 sqrt - //failure case: 2^63 < sqrt(2^127) - let planar_radicand=radicand.sqrt(); - //TODO: one or two newtons - //sort roots ascending and avoid taking the difference of large numbers - match (a2pos,Fixed::::ZERO[Ratio::new(-a1-planar_radicand,a2*2),Ratio::new(a0*2,-a1-planar_radicand)].into(), - (true, false)=>[Ratio::new(a0*2,-a1+planar_radicand),Ratio::new(-a1+planar_radicand,a2*2)].into(), - (false,true )=>[Ratio::new(a0*2,-a1-planar_radicand),Ratio::new(-a1-planar_radicand,a2*2)].into(), - (false,false)=>[Ratio::new(-a1+planar_radicand,a2*2),Ratio::new(a0*2,-a1+planar_radicand)].into(), - } - }, - Ordering::Equal=>ArrayVec::from_iter([Ratio::new(a1,a2*-2)]), - Ordering::Less=>ArrayVec::new_const(), - } -} -#[inline] -pub fn zeroes1(a0:Fixed,a1:Fixed)->ArrayVec,Fixed>,2>{ - if a1==Fixed::::ZERO{ - ArrayVec::new_const() - }else{ - ArrayVec::from_iter([Ratio::new(-a0,a1)]) - } -}