From 21e29aa63e25c612e4a083b6805fa06a3257ffe9 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 15 Nov 2023 18:00:14 -0800 Subject: [PATCH] implement MinkowskiMesh::face_edges MinkowskiFace::EdgeEdge case --- src/model_physics.rs | 80 +++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 20 deletions(-) diff --git a/src/model_physics.rs b/src/model_physics.rs index cfc4ac7..4bd215a 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -564,31 +564,71 @@ impl MeshQuery for MinkowskiMesh<'_>{ }).collect()) }, MinkowskiFace::EdgeEdge(e0,e1)=>{ - /* let e0v=self.mesh0.edge_verts(e0); + let e0f=self.mesh0.edge_faces(e0); + let edge0_n=self.mesh0.edge_n(e0); let e1v=self.mesh1.edge_verts(e1); - let [r0,r1]=e0v.map(|vert_id0|{ - //sort e1 ends by e0 edge dir to get v1 - //find face normal formulation without cross products - let v1=if 0<(e0.v1-e0.v0).dot(e1.v1-e1.v0){ - e1.v0 - }else{ - e1.v1 - }; - (MinkowskiEdge::VertEdge(vert_id0,e1),MinkowskiFace::FaceVert(face_id0,v1)) + let e1f=self.mesh1.edge_faces(e1); + let edge1_n=self.mesh1.edge_n(e1); + //populate algorithm variables based on known parity + //I don't like that this arbitrarily picks a face to test against! + let (e0v0_face_id1,e0v1_face_id1)=if edge0_n.dot(self.mesh1.face_nd(e1f[0]).0)<=Planar64::ZERO{ + (e1f[1],e1f[0]) + }else{ + (e1f[0],e1f[1]) + }; + let [r0,r1]=[(e0v[0],e0v0_face_id1),(e0v[1],e0v1_face_id1)].map(|(vert_id0,edge_face_id1)|{ + (MinkowskiEdge::VertEdge(vert_id0,e1),{ + let mut best_edge=None; + let mut best_d=Planar64::MAX; + let edge_face1_n=self.mesh1.face_nd(edge_face_id1).0; + let v0e=self.mesh0.vert_directed_edges(vert_id0); + for &directed_edge_id0 in v0e.iter(){ + let edge0_n=self.mesh0.directed_edge_n(directed_edge_id0); + if edge_face1_n.dot(edge0_n){ let face0_n=self.mesh0.face_nd(f0).0;