diff --git a/src/face_crawler.rs b/src/face_crawler.rs index 9faf38a..153f42c 100644 --- a/src/face_crawler.rs +++ b/src/face_crawler.rs @@ -24,7 +24,7 @@ type MinkowskiTransition=Transition::zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){ + for dt in Fixed::<2,64>::zeroes2((n.dot(body.position)-d).fix_2()*2,n.dot(body.velocity).fix_2()*2,n.dot(body.acceleration).fix_2()){ if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){ best_time=dt; best_transtition=MinkowskiTransition::Hit(face_id,dt); @@ -38,7 +38,7 @@ type MinkowskiTransition=Transition::zeroes2(n.dot(body.position*2-(mesh.vert(verts[0])+mesh.vert(verts[1]))).fix_4(),n.dot(body.velocity).fix_4()*2,n.dot(body.acceleration).fix_4()){ + for dt in Fixed::<2,64>::zeroes2(n.dot(body.position*2-(mesh.vert(verts[0])+mesh.vert(verts[1]))).fix_2(),n.dot(body.velocity).fix_2()*2,n.dot(body.acceleration).fix_2()){ if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){ best_time=dt; best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Edge(directed_edge_id.as_undirected()),dt); @@ -58,7 +58,7 @@ type MinkowskiTransition=Transition::zeroes2(n.dot(delta_pos).fix_4(),n.dot(body.velocity).fix_4()*2,n.dot(body.acceleration).fix_4()){ + for dt in Fixed::<2,64>::zeroes2(n.dot(delta_pos).fix_2(),n.dot(body.velocity).fix_2()*2,n.dot(body.acceleration).fix_2()){ if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){ best_time=dt; best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Face(edge_face_id),dt); @@ -72,7 +72,7 @@ type MinkowskiTransition=Transition::zeroes2((n.dot(body.position-mesh.vert(vert_id)))*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){ if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){ - let dt=Ratio::new(dt.num.fix_4(),dt.den.fix_4()); + let dt=Ratio::new(dt.num.fix_2(),dt.den.fix_2()); best_time=dt; best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Vert(vert_id),dt); break; @@ -88,7 +88,7 @@ type MinkowskiTransition=Transition::zeroes2((n.dot(body.position-mesh.vert(vert_id)))*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){ if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){ - let dt=Ratio::new(dt.num.fix_4(),dt.den.fix_4()); + let dt=Ratio::new(dt.num.fix_2(),dt.den.fix_2()); best_time=dt; best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Edge(directed_edge_id.as_undirected()),dt); break; @@ -108,11 +108,11 @@ type MinkowskiCrawlResult=CrawlResultMinkowskiCrawlResult{ let mut body_time={ let r=(start_time-relative_body.time).to_ratio(); - Ratio::new(r.num.fix_4(),r.den.fix_4()) + Ratio::new(r.num.fix_2(),r.den.fix_2()) }; let time_limit={ let r=(time_limit-relative_body.time).to_ratio(); - Ratio::new(r.num.fix_4(),r.den.fix_4()) + Ratio::new(r.num.fix_2(),r.den.fix_2()) }; for _ in 0..20{ match next_transition(&fev,body_time,mesh,relative_body,time_limit){ diff --git a/src/model_physics.rs b/src/model_physics.rs index 6925e36..cb6bfe0 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -599,7 +599,7 @@ enum EV{ Edge(MinkowskiEdge), } -pub type GigaTime=Ratio,Fixed<4,128>>; +pub type GigaTime=Ratio,Fixed<2,64>>; impl MinkowskiMesh<'_>{ pub fn minkowski_sum<'a>(mesh0:TransformedMesh<'a>,mesh1:TransformedMesh<'a>)->MinkowskiMesh<'a>{ @@ -743,7 +743,7 @@ impl MinkowskiMesh<'_>{ //determine when it passes an edge ("sliding off" case) let mut best_time={ let r=(time_limit-relative_body.time).to_ratio(); - Ratio::new(r.num.fix_4(),r.den.fix_4()) + Ratio::new(r.num.fix_2(),r.den.fix_2()) }; let mut best_edge=None; let face_n=self.face_nd(contact_face_id).0; @@ -755,7 +755,7 @@ impl MinkowskiMesh<'_>{ let d=n.dot(self.vert(verts[0])+self.vert(verts[1])); //WARNING! d outside of *2 //WARNING: truncated precision - for dt in Fixed::<4,128>::zeroes2(((n.dot(relative_body.position))*2-d).fix_4(),n.dot(relative_body.velocity).fix_4()*2,n.dot(relative_body.acceleration).fix_4()){ + for dt in Fixed::<2,64>::zeroes2(((n.dot(relative_body.position))*2-d).fix_2(),n.dot(relative_body.velocity).fix_2()*2,n.dot(relative_body.acceleration).fix_2()){ if dt.num.is_positive()&&dt.lt_ratio(best_time)&&n.dot(relative_body.extrapolated_velocity_ratio_dt(dt)).is_negative(){ best_time=dt; best_edge=Some(directed_edge_id); @@ -849,7 +849,7 @@ impl MeshQuery for MinkowskiM let &[e1f0,e1f1]=self.mesh1.edge_faces(e1).borrow(); Cow::Owned([(e1f1,false),(e1f0,true)].map(|(edge_face_id1,face_parity)|{ let mut best_edge=None; - let mut best_d:Ratio,Fixed<8,256>>=Ratio::new(Fixed::ZERO,Fixed::ONE); + let mut best_d:Ratio,Fixed<2,64>>=Ratio::new(Fixed::ZERO,Fixed::ONE); let edge_face1_n=self.mesh1.face_nd(edge_face_id1).0; let edge_face1_nn=edge_face1_n.dot(edge_face1_n); for &directed_edge_id0 in v0e.iter(){ @@ -860,7 +860,7 @@ impl MeshQuery for MinkowskiM let edge0_nn=edge0_n.dot(edge0_n); // Assume not every number is huge // TODO: revisit this - let dd=(d*d)/(edge_face1_nn*edge0_nn); + let dd=(d*d).fix_2()/(edge_face1_nn*edge0_nn).fix_2(); if best_d for MinkowskiM let &[e0f0,e0f1]=self.mesh0.edge_faces(e0).borrow(); Cow::Owned([(e0f0,true),(e0f1,false)].map(|(edge_face_id0,face_parity)|{ let mut best_edge=None; - let mut best_d:Ratio,Fixed<8,256>>=Ratio::new(Fixed::ZERO,Fixed::ONE); + let mut best_d:Ratio,Fixed<2,64>>=Ratio::new(Fixed::ZERO,Fixed::ONE); let edge_face0_n=self.mesh0.face_nd(edge_face_id0).0; let edge_face0_nn=edge_face0_n.dot(edge_face0_n); for &directed_edge_id1 in v1e.iter(){ @@ -887,7 +887,7 @@ impl MeshQuery for MinkowskiM let d=edge_face0_n.dot(edge1_n); if d.is_negative(){ let edge1_nn=edge1_n.dot(edge1_n); - let dd=(d*d)/(edge_face0_nn*edge1_nn); + let dd=(d*d).fix_2()/(edge_face0_nn*edge1_nn).fix_2(); if best_d