diff --git a/src/physics.rs b/src/physics.rs index 74e9ae5..df68b4f 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -843,7 +843,7 @@ impl Body{ self.velocity=self.extrapolated_velocity(time); self.time=time; } - pub fn extrapolated_position_ratio_dt(&self,dt:integer::Ratio)->Planar64Vec3 + pub fn extrapolated_position_ratio_dt(&self,dt:integer::Ratio)->Planar64Vec3 where // Why? // All of this can be removed with const generics because the type can be specified as @@ -858,29 +858,27 @@ impl Body{ Num:core::ops::Mul, Den:core::ops::Mul, D2:Copy, - Planar64:core::ops::Mul, - N4:core::ops::Add, - N6:integer::Divide, + Planar64:core::ops::Mul, + N4:integer::Divide, T1:integer::Fix, { // a*dt^2/2 + v*dt + p // (a*dt/2+v)*dt+p - ((self.acceleration.map(|elem|dt*elem/2)+self.velocity).map(|elem|dt.mul_ratio(elem))+self.position) - .map(|elem|elem.divide().fix()) + (self.acceleration.map(|elem|dt*elem/2)+self.velocity).map(|elem|dt.mul_ratio(elem)) + .map(|elem|elem.divide().fix())+self.position } - pub fn extrapolated_velocity_ratio_dt(&self,dt:integer::Ratio)->Planar64Vec3 + pub fn extrapolated_velocity_ratio_dt(&self,dt:integer::Ratio)->Planar64Vec3 where Num:Copy, Den:Copy, Num:core::ops::Mul, - Planar64:core::ops::Mul, - N1:core::ops::Add, - N3:integer::Divide, + Planar64:core::ops::Mul, + N1:integer::Divide, T1:integer::Fix, { // a*dt + v - (self.acceleration.map(|elem|dt*elem)+self.velocity) - .map(|elem|elem.divide().fix()) + self.acceleration.map(|elem|dt*elem) + .map(|elem|elem.divide().fix())+self.velocity } pub fn advance_time_ratio_dt(&mut self,dt:model_physics::GigaTime){ self.position=self.extrapolated_position_ratio_dt(dt);