floor(x+1)==floor(x)+1

This commit is contained in:
Quaternions 2024-09-26 18:44:12 -07:00
parent 72c91558e7
commit 4eda90e178

View File

@ -843,7 +843,7 @@ impl Body{
self.velocity=self.extrapolated_velocity(time);
self.time=time;
}
pub fn extrapolated_position_ratio_dt<Num,Den,N1,D1,N2,N3,D2,N4,N5,N6,T1>(&self,dt:integer::Ratio<Num,Den>)->Planar64Vec3
pub fn extrapolated_position_ratio_dt<Num,Den,N1,D1,N2,N3,D2,N4,T1>(&self,dt:integer::Ratio<Num,Den>)->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<N3,Output=N4>,
Den:core::ops::Mul<D1,Output=D2>,
D2:Copy,
Planar64:core::ops::Mul<D2,Output=N5>,
N4:core::ops::Add<N5,Output=N6>,
N6:integer::Divide<D2,Output=T1>,
Planar64:core::ops::Mul<D2,Output=N4>,
N4:integer::Divide<D2,Output=T1>,
T1:integer::Fix<Planar64>,
{
// 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<Num,Den,N1,N2,N3,T1>(&self,dt:integer::Ratio<Num,Den>)->Planar64Vec3
pub fn extrapolated_velocity_ratio_dt<Num,Den,N1,T1>(&self,dt:integer::Ratio<Num,Den>)->Planar64Vec3
where
Num:Copy,
Den:Copy,
Num:core::ops::Mul<Planar64,Output=N1>,
Planar64:core::ops::Mul<Den,Output=N2>,
N1:core::ops::Add<N2,Output=N3>,
N3:integer::Divide<Den,Output=T1>,
Planar64:core::ops::Mul<Den,Output=N1>,
N1:integer::Divide<Den,Output=T1>,
T1:integer::Fix<Planar64>,
{
// 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);