This commit is contained in:
2025-11-20 09:05:29 -08:00
parent b0668136d6
commit 565b53138c

View File

@@ -5,11 +5,6 @@ use crate::model::TransformedMesh;
// This algorithm is based on Lua code
// written by Trey Reynolds in 2021
// local function minimumDifference(
// queryP, radiusP,
// queryQ, radiusQ,
// exitRadius, testIntersection
// )
pub struct MinimumDifference{
distance:Planar64,
@@ -19,6 +14,11 @@ pub struct MinimumDifference{
q_norm:Planar64Vec3,
}
// local function minimumDifference(
// queryP, radiusP,
// queryQ, radiusQ,
// exitRadius, testIntersection
// )
pub fn minimum_difference(p:&TransformedMesh,q:&TransformedMesh)->Option<MinimumDifference>{
// local initialAxis = queryQ() - queryP()
// local newPoint0 = queryP(initialAxis)
@@ -27,51 +27,52 @@ pub fn minimum_difference(p:&TransformedMesh,q:&TransformedMesh)->Option<Minimum
// exitRadius = testIntersection and 0 or exitRadius or 1/0
// for _ = 1, 100 do
// direction, a0, a1, b0, b1, c0, c1, d0, d1 = reduceSimplex(newPoint0, newPoint1, a0, a1, b0, b1, c0, c1)
// local a, b, c, d = getRelativeSimplex(a0, a1, b0, b1, c0, c1, d0, d1)
loop{
// direction, a0, a1, b0, b1, c0, c1, d0, d1 = reduceSimplex(newPoint0, newPoint1, a0, a1, b0, b1, c0, c1)
// local a, b, c, d = getRelativeSimplex(a0, a1, b0, b1, c0, c1, d0, d1)
// if a and b and c and d then
// if testIntersection then
// return true
// end
// local norm, dist, u0, u1, v0, v1, w0, w1 = expand(queryP, queryQ, a0, a1, b0, b1, c0, c1, d0, d1, 1e-5)
// if norm then
// local posP, posQ = decompose(Vector3.zero, u0, u1, v0, v1, w0, w1)
// return true, -dist - radiusP - radiusQ,
// posP - radiusP*norm, -norm,
// posQ + radiusQ*norm, norm
// end
// return nil
// end
// if a and b and c and d then
// if testIntersection then
// return true
// end
// local norm, dist, u0, u1, v0, v1, w0, w1 = expand(queryP, queryQ, a0, a1, b0, b1, c0, c1, d0, d1, 1e-5)
// if norm then
// local posP, posQ = decompose(Vector3.zero, u0, u1, v0, v1, w0, w1)
// return true, -dist - radiusP - radiusQ,
// posP - radiusP*norm, -norm,
// posQ + radiusQ*norm, norm
// end
// return nil
// end
// newPoint0 = queryP(-direction)
// newPoint1 = queryQ(direction)
// local newPoint = newPoint1 - newPoint0
// newPoint0 = queryP(-direction)
// newPoint1 = queryQ(direction)
// local newPoint = newPoint1 - newPoint0
// if -direction:Dot(newPoint) > (exitRadius + radiusP + radiusQ)*direction.magnitude then
// return false
// end
// if
// direction:Dot(newPoint - a) <= 0 or
// absDet(newPoint, a, b, c) < 1e-6
// then
// local norm = direction.unit
// local dist = a:Dot(norm)
// local hits = -dist < radiusP + radiusQ
// if testIntersection then
// return hits
// end
// if -dist <= exitRadius + radiusP + radiusQ then
// local posP, posQ = decompose(Vector3.zero, a0, a1, b0, b1, c0, c1)
// return hits, -dist - radiusP - radiusQ,
// posP - radiusP*norm, -norm,
// posQ + radiusQ*norm, norm
// end
// return false
// end
// end
// if -direction:Dot(newPoint) > (exitRadius + radiusP + radiusQ)*direction.magnitude then
// return false
// end
// if
// direction:Dot(newPoint - a) <= 0 or
// absDet(newPoint, a, b, c) < 1e-6
// then
// local norm = direction.unit
// local dist = a:Dot(norm)
// local hits = -dist < radiusP + radiusQ
// if testIntersection then
// return hits
// end
// if -dist <= exitRadius + radiusP + radiusQ then
// local posP, posQ = decompose(Vector3.zero, a0, a1, b0, b1, c0, c1)
// return hits, -dist - radiusP - radiusQ,
// posP - radiusP*norm, -norm,
// posQ + radiusQ*norm, norm
// end
// return false
// end
panic!("quit underlining all my code!");
}
// return nil
None
}