implement MinkowskiMesh::farthest_vert

This commit is contained in:
Quaternions 2023-11-15 21:05:18 -08:00
parent 751ccf57ca
commit 559a38b607
2 changed files with 17 additions and 0 deletions

View File

@ -415,6 +415,7 @@ impl Planar64{
pub const ZERO:Self=Self(0);
pub const ONE:Self=Self(1<<32);
pub const MAX:Self=Self(i64::MAX);
pub const MIN:Self=Self(i64::MIN);
#[inline]
pub const fn int(num:i32)->Self{
Self(Self::ONE.0*num as i64)

View File

@ -244,6 +244,19 @@ impl TransformedMesh<'_>{
normal_transform,
}
}
fn farthest_vert(&self,dir:Planar64Vec3)->VertId{
let best_dot=Planar64::MIN;
let best_vert;
for (i,vert) in self.mesh.verts.iter().enumerate(){
let p=self.transform.transform_point3(vert.0);
let d=dir.dot(p);
if best_dot<d{
best_dot=d;
best_vert=VertId(i);
}
}
best_vert
}
#[inline]
fn vert_directed_edges(&self,vert_id:VertId)->Cow<Vec<DirectedEdgeId>>{
self.mesh.vert_directed_edges(vert_id)
@ -321,6 +334,9 @@ impl MinkowskiMesh<'_>{
mesh1,
}
}
fn farthest_vert(&self,dir:Planar64Vec3)->MinkowskiVert{
MinkowskiVert::VertVert(self.mesh0.farthest_vert(dir),self.mesh1.farthest_vert(-dir))
}
fn closest_fev(&self,point:Planar64Vec3)->FEV<MinkowskiFace,MinkowskiEdge,MinkowskiVert>{
//put some genius code right here instead of this
//assume that point is outside the mesh and nonzero