Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Add M3 geometry evidence project and diagnostics
Yuechen Li4f52ad6b4506
diff --git a/Aetheris.Geometry.Tests/ClosestPointQueryTests.cs b/Aetheris.Geometry.Tests/ClosestPointQueryTests.csnew file mode 100644index 00000000..118db041--- /dev/null+++ b/Aetheris.Geometry.Tests/ClosestPointQueryTests.cs@@ -0,0 +1,110 @@+using Aetheris.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Surfacing;+using Xunit;++namespace Aetheris.Geometry.Tests;++public sealed class ClosestPointQueryTests+{+ [Fact]+ public void Point_segment_projection_is_certified_and_clamps_to_authored_domain()+ {+ var segment=Line("line",new(0,0,0),new(10,0,0));+ var result=ClosestPointQuery.Between(new Point3D(12,3,0),segment);+ Assert.Equal(DistanceQueryStatus.Available,result.Status);Assert.Equal(DistanceRelation.Separated,result.Relation);+ Assert.Equal(PredicateEvidenceKind.Certified,result.Evidence);Assert.Equal(double.Sqrt(13),result.ComputedDistance!.Value,12);+ Assert.Equal(10,result.ParameterOnB!.T);Assert.Equal(DistanceQueryPolicy.Default,result.ToleranceUsed);+ }++ [Fact]+ public void Floating_noise_is_raw_within_tolerance_and_never_fake_coincidence()+ {+ var a=Line("a",new(0,0,0),new(10,0,0));var b=Line("b",new(0,0,5e-7),new(10,0,5e-7));+ var loose=ClosestPointQuery.Between(a,b);+ var tight=ClosestPointQuery.Between(a,b,new(){LinearTolerance=1e-8});+ Assert.Equal(5e-7,loose.ComputedDistance!.Value,14);Assert.Equal(1e-6,loose.ToleranceUsed.LinearTolerance);+ Assert.Equal(DistanceRelation.WithinTolerance,loose.Relation);Assert.NotEqual(DistanceRelation.Coincident,loose.Relation);+ Assert.Equal(loose.ComputedDistance,tight.ComputedDistance);Assert.Equal(DistanceRelation.Separated,tight.Relation);+ }++ [Fact]+ public void Same_authored_identity_earns_structural_coincidence_without_direction_claim()+ {+ var a=Line("shared-locus",new(0,0,0),new(1,0,0));var reversed=Line("shared-locus",new(1,0,0),new(0,0,0));+ var result=ClosestPointQuery.Between(a,reversed);+ Assert.Equal(DistanceRelation.Coincident,result.Relation);Assert.Equal(PredicateEvidenceKind.Structural,result.Evidence);+ Assert.Equal(0,result.ComputedDistance);Assert.Equal(0,result.Statistics.CandidateCount);+ }++ [Fact]+ public void Generic_point_patch_considers_interior_boundary_and_corners()+ {+ var patch=Patch("saddle",(u,v)=>new(u,v,u*u-v*v));+ var result=ClosestPointQuery.Between(new Point3D(0,0,2),patch);+ Assert.Equal(DistanceQueryStatus.Available,result.Status);Assert.Equal(double.Sqrt(2),result.ComputedDistance!.Value,10);+ Assert.Equal(PredicateEvidenceKind.ToleranceBounded,result.Evidence);Assert.NotNull(result.DistanceLowerBound);+ Assert.Equal(1,double.Abs(result.ParameterOnB!.U!.Value),12);Assert.Equal(0,result.ParameterOnB.V!.Value,12);+ }++ [Fact]+ public void Generic_bounded_circle_projection_refines_both_global_resolutions()+ {+ var circle=BoundedParametricCurve3.Procedural("circle",new(0,2*double.Pi),t=>(new Point3D(5*double.Cos(t),5*double.Sin(t),0),new Vector3D(-5*double.Sin(t),5*double.Cos(t),0)),"test");+ var result=ClosestPointQuery.Between(new Point3D(7,0,0),circle);+ Assert.Equal(DistanceQueryStatus.Available,result.Status);Assert.Equal(2,result.ComputedDistance!.Value,10);+ Assert.Equal(PredicateEvidenceKind.ToleranceBounded,result.Evidence);+ }++ [Fact]+ public void Generic_curve_curve_curve_patch_and_patch_patch_are_deterministic()+ {+ var parabola=Curve("parabola",t=>new(t,t*t,2));var parabola2=Curve("parabola-2",t=>new(t,t*t,4));+ var plane=Patch("plane",(u,v)=>new(u,v,0));var plane3=Patch("plane-3",(u,v)=>new(u,v,3));+ var cc=ClosestPointQuery.Between(parabola,parabola2);var cp=ClosestPointQuery.Between(parabola,plane);var pp=ClosestPointQuery.Between(plane,plane3);+ Assert.Equal(2,cc.ComputedDistance!.Value,10);Assert.Equal(2,cp.ComputedDistance!.Value,10);Assert.Equal(3,pp.ComputedDistance!.Value,10);+ Assert.All(new[]{cc,cp,pp},r=>Assert.Equal(DistanceQueryStatus.Available,r.Status));+ var repeated=ClosestPointQuery.Between(plane,plane3);+ Assert.Equal(pp.ComputedDistance,repeated.ComputedDistance);Assert.Equal(pp.PointOnA,repeated.PointOnA);+ Assert.Equal(pp.PointOnB,repeated.PointOnB);Assert.Equal(pp.Statistics,repeated.Statistics);+ }++ [Fact]+ public void Panel_edges_dogfood_public_clearance_query()+ {+ var panel=RuledCanopyPanelTemplate.Create("clearance-panel",10,4,0).Panel!;+ var result=ClosestPointQuery.Between(panel["South"].AuthoredCurve,panel["North"].AuthoredCurve);+ Assert.Equal(DistanceQueryStatus.Available,result.Status);Assert.Equal(DistanceRelation.Separated,result.Relation);+ Assert.Equal(PredicateEvidenceKind.Certified,result.Evidence);Assert.Equal(4,result.ComputedDistance!.Value,10);+ }++ [Fact]+ public void Non_finite_generic_evaluation_returns_unknown_with_typed_diagnostic()+ {+ var bad=BoundedParametricCurve3.Procedural("bad",new(-1,1),t=>(new Point3D(double.NaN,0,0),new Vector3D(1,0,0)),"fixture");+ var result=ClosestPointQuery.Between(Point3D.Origin,bad);+ Assert.Equal(DistanceQueryStatus.Unknown,result.Status);Assert.Equal(DistanceRelation.Unknown,result.Relation);+ Assert.Contains(result.Diagnostics,d=>d.Code==GeometryQueryDiagnosticCode.NonFiniteEvaluation);+ }++ [Fact]+ public void Insufficient_whole_domain_budget_returns_unknown_without_a_local_minimum_claim()+ {+ var a=Patch("budget-a",(u,v)=>new(u,v,0));var b=Patch("budget-b",(u,v)=>new(u,v,1));+ var result=ClosestPointQuery.Between(a,b,new(){SubdivisionBudget=16});+ Assert.Equal(DistanceQueryStatus.Unknown,result.Status);Assert.Equal(DistanceRelation.Unknown,result.Relation);+ Assert.Null(result.ComputedDistance);Assert.Contains(result.Diagnostics,d=>d.Code==GeometryQueryDiagnosticCode.SubdivisionBudgetExhausted);+ }++ [Fact]+ public void Clearance_expectation_validates_without_moving_geometry()+ {+ var result=ClosestPointQuery.Between(Line("a",new(0,0,0),new(1,0,0)),Line("b",new(0,0,1),new(1,0,1)));+ Assert.True(new ClearanceExpectation(.9).Evaluate(result).Satisfied);Assert.False(new ClearanceExpectation(1.1).Evaluate(result).Satisfied);+ }++ private static BoundedParametricCurve3 Line(string id,Point3D a,Point3D b)=>BoundedParametricCurve3.LineSegment(id,a,b,"test");+ private static BoundedParametricCurve3 Curve(string id,Func<double,Point3D> f)=>BoundedParametricCurve3.Procedural(id,new(-1,1),t=>(f(t),new Vector3D(1,2*t,0)),"test");+ private static BoundedParametricPatch3 Patch(string id,Func<double,double,Point3D> f)=>BoundedParametricPatch3.Procedural(id,+ new(new(-1,1),new(-1,1)),(u,v)=>new(f(u,v),new Vector3D(1,0,2*u),new Vector3D(0,1,-2*v),null,false),"test");+}diff --git a/Aetheris.Geometry/ClosestPointQuery.cs b/Aetheris.Geometry/ClosestPointQuery.csnew file mode 100644index 00000000..78b64f45--- /dev/null+++ b/Aetheris.Geometry/ClosestPointQuery.cs@@ -0,0 +1,208 @@+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Numerics;++namespace Aetheris.Geometry;++public enum DistanceRelation { Separated, WithinTolerance, Coincident, Unknown }+public enum DistanceQueryStatus { Available, Unknown }++/// <summary>+/// Mandatory interpretation and work policy for bounded distance queries. The default model-space+/// tolerance is the kernel CAD tolerance (1e-6 mm); relative tolerance is applied to the largest+/// coordinate/distance scale observed by the result.+/// </summary>+public sealed record DistanceQueryPolicy+{+ public static DistanceQueryPolicy Default { get; } = new();+ public double LinearTolerance { get; init; } = ToleranceContext.Default.Linear;+ public double RelativeTolerance { get; init; } = ToleranceContext.Default.Relative;+ public double ParameterTolerance { get; init; } = 1e-10;+ public int IterationBudget { get; init; } = 96;+ public int SubdivisionBudget { get; init; } = 10_000;++ public DistanceQueryPolicy Validate()+ {+ Positive(LinearTolerance, nameof(LinearTolerance));+ Positive(RelativeTolerance, nameof(RelativeTolerance));+ Positive(ParameterTolerance, nameof(ParameterTolerance));+ if (IterationBudget < 1) throw new ArgumentOutOfRangeException(nameof(IterationBudget));+ if (SubdivisionBudget < 16) throw new ArgumentOutOfRangeException(nameof(SubdivisionBudget));+ return this;+ }++ public double EffectiveTolerance(double scale) => double.Max(LinearTolerance, RelativeTolerance * double.Max(1d, double.Abs(scale)));+ private static void Positive(double value, string name) { if (!double.IsFinite(value) || value <= 0d) throw new ArgumentOutOfRangeException(name); }+}++public sealed record DistanceParameters(double? T = null, double? U = null, double? V = null);+public sealed record DistanceQueryStatistics(int Iterations, int Subdivisions, int CandidateCount, bool BudgetExhausted);++public sealed record ClosestPointResult(+ DistanceQueryStatus Status,+ DistanceRelation Relation,+ double? ComputedDistance,+ double? SquaredDistance,+ double? DistanceLowerBound,+ double? DistanceUpperBound,+ Point3D? PointOnA,+ Point3D? PointOnB,+ DistanceParameters? ParameterOnA,+ DistanceParameters? ParameterOnB,+ DistanceQueryPolicy ToleranceUsed,+ PredicateEvidenceKind Evidence,+ double? Residual,+ DistanceQueryStatistics Statistics,+ GeometryIdentity? IdentityA,+ GeometryIdentity? IdentityB,+ GeometryProvenance? ProvenanceA,+ GeometryProvenance? ProvenanceB,+ IReadOnlyList<GeometryQueryDiagnostic> Diagnostics);++/// <summary>+/// Observational closest-point/minimum-distance queries. Results never author intersections,+/// topology, contact order, or motion. A numerical zero only means WithinTolerance unless+/// structural identity or a certified argument establishes coincidence.+/// </summary>+public static class ClosestPointQuery+{+ public static ClosestPointResult Between(Point3D point, BoundedParametricCurve3 curve) => Between(point, curve, DistanceQueryPolicy.Default);+ public static ClosestPointResult Between(Point3D point, BoundedParametricCurve3 curve, DistanceQueryPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(curve); Validate(point, policy);+ if (curve.NativeFamily == "Line3") return PointSegment(point, curve, policy);+ return Optimize([curve.Domain], x => (point, curve.Evaluate(x[0])), policy, null, curve,+ _ => null, x => new(T: x[0]));+ }++ public static ClosestPointResult Between(BoundedParametricCurve3 curve, Point3D point) => Swap(Between(point, curve));+ public static ClosestPointResult Between(BoundedParametricCurve3 curve, Point3D point, DistanceQueryPolicy policy) => Swap(Between(point, curve, policy));++ public static ClosestPointResult Between(Point3D point, BoundedParametricPatch3 patch) => Between(point, patch, DistanceQueryPolicy.Default);+ public static ClosestPointResult Between(Point3D point, BoundedParametricPatch3 patch, DistanceQueryPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(patch); Validate(point, policy);+ return Optimize([ToDomain(patch.Domain.U), ToDomain(patch.Domain.V)], x => (point, patch.Evaluate(x[0], x[1]).Point), policy,+ null, patch, _ => null, x => new(U: x[0], V: x[1]));+ }++ public static ClosestPointResult Between(BoundedParametricPatch3 patch, Point3D point) => Swap(Between(point, patch));+ public static ClosestPointResult Between(BoundedParametricPatch3 patch, Point3D point, DistanceQueryPolicy policy) => Swap(Between(point, patch, policy));++ public static ClosestPointResult Between(BoundedParametricCurve3 a, BoundedParametricCurve3 b) => Between(a, b, DistanceQueryPolicy.Default);+ public static ClosestPointResult Between(BoundedParametricCurve3 a, BoundedParametricCurve3 b, DistanceQueryPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(a); ArgumentNullException.ThrowIfNull(b); policy.Validate();+ if (a.Identity == b.Identity) return Structural(a, b, policy, a.Evaluate(a.Domain.Minimum), new(T: a.Domain.Minimum), new(T: b.Domain.Minimum));+ if (a.NativeFamily == "Line3" && b.NativeFamily == "Line3") return SegmentSegment(a, b, policy);+ return Optimize([a.Domain, b.Domain], x => (a.Evaluate(x[0]), b.Evaluate(x[1])), policy, a, b,+ x => new(T: x[0]), x => new(T: x[1]));+ }++ public static ClosestPointResult Between(BoundedParametricCurve3 curve, BoundedParametricPatch3 patch) => Between(curve, patch, DistanceQueryPolicy.Default);+ public static ClosestPointResult Between(BoundedParametricCurve3 curve, BoundedParametricPatch3 patch, DistanceQueryPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(curve); ArgumentNullException.ThrowIfNull(patch); policy.Validate();+ return Optimize([curve.Domain, ToDomain(patch.Domain.U), ToDomain(patch.Domain.V)],+ x => (curve.Evaluate(x[0]), patch.Evaluate(x[1], x[2]).Point), policy, curve, patch,+ x => new(T: x[0]), x => new(U: x[1], V: x[2]));+ }++ public static ClosestPointResult Between(BoundedParametricPatch3 patch, BoundedParametricCurve3 curve) => Swap(Between(curve, patch));+ public static ClosestPointResult Between(BoundedParametricPatch3 patch, BoundedParametricCurve3 curve, DistanceQueryPolicy policy) => Swap(Between(curve, patch, policy));++ public static ClosestPointResult Between(BoundedParametricPatch3 a, BoundedParametricPatch3 b) => Between(a, b, DistanceQueryPolicy.Default);+ public static ClosestPointResult Between(BoundedParametricPatch3 a, BoundedParametricPatch3 b, DistanceQueryPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(a); ArgumentNullException.ThrowIfNull(b); policy.Validate();+ if (a.Identity == b.Identity)+ {+ var p = a.Evaluate(a.Domain.U.Minimum, a.Domain.V.Minimum).Point;+ return Structural(a, b, policy, p, new(U: a.Domain.U.Minimum, V: a.Domain.V.Minimum), new(U: b.Domain.U.Minimum, V: b.Domain.V.Minimum));+ }+ return Optimize([ToDomain(a.Domain.U), ToDomain(a.Domain.V), ToDomain(b.Domain.U), ToDomain(b.Domain.V)],+ x => (a.Evaluate(x[0], x[1]).Point, b.Evaluate(x[2], x[3]).Point), policy, a, b,+ x => new(U: x[0], V: x[1]), x => new(U: x[2], V: x[3]));+ }++ private static ClosestPointResult PointSegment(Point3D point, BoundedParametricCurve3 curve, DistanceQueryPolicy policy)+ {+ var p0 = curve.Evaluate(curve.Domain.Minimum); var p1 = curve.Evaluate(curve.Domain.Maximum); var d = p1 - p0;+ var fraction = double.Clamp((point - p0).Dot(d) / d.LengthSquared, 0d, 1d);+ var parameter = curve.Domain.Minimum + fraction * curve.Domain.Length; var closest = curve.Evaluate(parameter);+ return Exact(point, closest, policy, null, curve, null, new(T: parameter), PredicateEvidenceKind.Certified);+ }++ private static ClosestPointResult SegmentSegment(BoundedParametricCurve3 a, BoundedParametricCurve3 b, DistanceQueryPolicy policy)+ {+ var p1 = a.Evaluate(a.Domain.Minimum); var q1 = a.Evaluate(a.Domain.Maximum);+ var p2 = b.Evaluate(b.Domain.Minimum); var q2 = b.Evaluate(b.Domain.Maximum);+ var d1=q1-p1;var d2=q2-p2;var r=p1-p2;var aa=d1.Dot(d1);var e=d2.Dot(d2);var f=d2.Dot(r);double s,t;+ var eps=1e-30;+ if(aa<=eps){s=0;t=double.Clamp(f/e,0,1);} else {var c=d1.Dot(r);if(e<=eps){t=0;s=double.Clamp(-c/aa,0,1);}else{var bb=d1.Dot(d2);var denom=aa*e-bb*bb;s=denom!=0?double.Clamp((bb*f-c*e)/denom,0,1):0;t=(bb*s+f)/e;if(t<0){t=0;s=double.Clamp(-c/aa,0,1);}else if(t>1){t=1;s=double.Clamp((bb-c)/aa,0,1);}}}+ var ta=a.Domain.Minimum+s*a.Domain.Length;var tb=b.Domain.Minimum+t*b.Domain.Length;+ return Exact(a.Evaluate(ta),b.Evaluate(tb),policy,a,b,new(T:ta),new(T:tb),PredicateEvidenceKind.Certified);+ }++ private static ClosestPointResult Optimize(ParameterDomain1[] domains, Func<double[],(Point3D A,Point3D B)> evaluate,+ DistanceQueryPolicy policy, object? a, object? b, Func<double[],DistanceParameters?> pa, Func<double[],DistanceParameters?> pb)+ {+ policy.Validate(); var diagnostics=new List<GeometryQueryDiagnostic>();+ var dimensions=domains.Length; var fineN=dimensions switch {1=>65,2=>33,3=>17,_=>9};+ while(Pow(fineN,dimensions)+Pow((fineN+1)/2,dimensions)>policy.SubdivisionBudget&&fineN>3)fineN-=2;+ var coarseN=(fineN+1)/2; var candidates=0;+ var subdivisionCount=Pow(coarseN,dimensions)+Pow(fineN,dimensions);+ if(subdivisionCount>policy.SubdivisionBudget)+ return Unknown(policy,a,b,[new(GeometryQueryDiagnosticCode.SubdivisionBudgetExhausted,$"The minimum deterministic {dimensions}D lattice requires {subdivisionCount} candidates; policy permits {policy.SubdivisionBudget}.")],0);+ Candidate coarse, fine;+ try { coarse=Grid(coarseN); fine=Grid(fineN); }+ catch(ArithmeticException ex){diagnostics.Add(new(GeometryQueryDiagnosticCode.NonFiniteEvaluation,ex.Message));return Unknown(policy,a,b,diagnostics,candidates);}+ var coarseRefined=Refine(coarse,coarseN,policy.IterationBudget/2,out var coarseIterations);+ var best=Refine(fine,fineN,policy.IterationBudget-coarseIterations,out var fineIterations);var iterations=coarseIterations+fineIterations;+ var scale=Scale(best.A,best.B,best.Distance);var tolerance=policy.EffectiveTolerance(scale);+ var residual=double.Abs(coarseRefined.Distance-best.Distance);var converged=residual<=tolerance;+ if(!converged)diagnostics.Add(new(GeometryQueryDiagnosticCode.SubdivisionBudgetExhausted,$"Bounded deterministic refinement did not stabilize within {tolerance:R}; best change was {residual:R}."));+ var relation=converged?Classify(best.Distance,tolerance):DistanceRelation.Unknown;+ var evidence=converged?PredicateEvidenceKind.ToleranceBounded:PredicateEvidenceKind.Unknown;+ var lower=double.Max(0d,best.Distance-residual);var status=converged?DistanceQueryStatus.Available:DistanceQueryStatus.Unknown;+ return new(status,relation,best.Distance,best.Distance*best.Distance,lower,best.Distance,best.A,best.B,pa(best.X),pb(best.X),policy,evidence,residual,+ new(iterations,subdivisionCount,candidates,!converged),Identity(a),Identity(b),Provenance(a),Provenance(b),diagnostics);++ Candidate Grid(int n){Candidate? current=null;var x0=new double[dimensions];Walk(0);return current!.Value;+ void Walk(int axis){if(axis==dimensions){var c=At((double[])x0.Clone());candidates++;if(current is null||c.Distance<current.Value.Distance)current=c;return;}for(var i=0;i<n;i++){x0[axis]=domains[axis].Minimum+domains[axis].Length*i/(n-1d);Walk(axis+1);}}}+ Candidate Refine(Candidate seed,int n,int maximumIterations,out int used)+ {var local=seed;var x=(double[])seed.X.Clone();var step=domains.Select(d=>d.Length/(n-1)).ToArray();+ for(used=0;used<maximumIterations;used++){var improved=false;for(var axis=0;axis<dimensions;axis++)foreach(var sign in new[]{-1d,1d})+ {var trial=(double[])x.Clone();trial[axis]=domains[axis].Clamp(trial[axis]+sign*step[axis]);var c=At(trial);candidates++;if(c.Distance<local.Distance){local=c;x=trial;improved=true;}}+ if(!improved){for(var i=0;i<step.Length;i++)step[i]*=.5;if(step.Select((v,i)=>v/domains[i].Length).Max()<=policy.ParameterTolerance)break;}}+ return local;}+ Candidate At(double[] values){var pair=evaluate(values);if(!Finite(pair.A)||!Finite(pair.B))throw new ArithmeticException("Distance objective produced a non-finite point.");return new(values,pair.A,pair.B,(pair.A-pair.B).Length);}+ }++ private static ClosestPointResult Exact(Point3D a,Point3D b,DistanceQueryPolicy policy,object? oa,object? ob,DistanceParameters? pa,DistanceParameters? pb,PredicateEvidenceKind evidence)+ {policy.Validate();var d=(a-b).Length;var tol=policy.EffectiveTolerance(Scale(a,b,d));return new(DistanceQueryStatus.Available,Classify(d,tol),d,d*d,d,d,a,b,pa,pb,policy,evidence,0,new(0,0,1,false),Identity(oa),Identity(ob),Provenance(oa),Provenance(ob),[]);}+ private static ClosestPointResult Structural(object a,object b,DistanceQueryPolicy policy,Point3D point,DistanceParameters pa,DistanceParameters pb)+ {policy.Validate();return new(DistanceQueryStatus.Available,DistanceRelation.Coincident,0,0,0,0,point,point,pa,pb,policy,PredicateEvidenceKind.Structural,0,new(0,0,0,false),Identity(a),Identity(b),Provenance(a),Provenance(b),[]);}+ private static ClosestPointResult Unknown(DistanceQueryPolicy p,object? a,object? b,List<GeometryQueryDiagnostic>d,int c)=>new(DistanceQueryStatus.Unknown,DistanceRelation.Unknown,null,null,null,null,null,null,null,null,p,PredicateEvidenceKind.Unknown,null,new(0,0,c,true),Identity(a),Identity(b),Provenance(a),Provenance(b),d);+ private static ClosestPointResult Swap(ClosestPointResult r)=>r with{PointOnA=r.PointOnB,PointOnB=r.PointOnA,ParameterOnA=r.ParameterOnB,ParameterOnB=r.ParameterOnA,IdentityA=r.IdentityB,IdentityB=r.IdentityA,ProvenanceA=r.ProvenanceB,ProvenanceB=r.ProvenanceA};+ private static DistanceRelation Classify(double d,double tolerance)=>d<=tolerance?DistanceRelation.WithinTolerance:DistanceRelation.Separated;+ private static ParameterDomain1 ToDomain(ParameterInterval2 d)=>new(d.Minimum,d.Maximum);+ private static int Pow(int value,int exponent){var result=1;for(var i=0;i<exponent;i++)result=checked(result*value);return result;}+ private static double Scale(Point3D a,Point3D b,double d)=>new[]{double.Abs(a.X),double.Abs(a.Y),double.Abs(a.Z),double.Abs(b.X),double.Abs(b.Y),double.Abs(b.Z),d}.Max();+ private static bool Finite(Point3D p)=>double.IsFinite(p.X)&&double.IsFinite(p.Y)&&double.IsFinite(p.Z);+ private static void Validate(Point3D p,DistanceQueryPolicy policy){ArgumentNullException.ThrowIfNull(policy);policy.Validate();if(!Finite(p))throw new ArgumentException("Query point must be finite.",nameof(p));}+ private static GeometryIdentity? Identity(object? x)=>x switch{BoundedParametricCurve3 c=>c.Identity,BoundedParametricPatch3 p=>p.Identity,_=>null};+ private static GeometryProvenance? Provenance(object? x)=>x switch{BoundedParametricCurve3 c=>c.Provenance,BoundedParametricPatch3 p=>p.GeometryProvenance,_=>null};+ private readonly record struct Candidate(double[] X,Point3D A,Point3D B,double Distance);+}++public enum ClearanceExpectationRelation { AtLeast, AtMost }+public sealed record ClearanceExpectation(double RequiredDistance, ClearanceExpectationRelation Relation = ClearanceExpectationRelation.AtLeast)+{+ public ClearanceExpectationResult Evaluate(ClosestPointResult result)+ {+ ArgumentNullException.ThrowIfNull(result);if(!double.IsFinite(RequiredDistance)||RequiredDistance<0)throw new ArgumentOutOfRangeException(nameof(RequiredDistance));+ var satisfied=result.Status==DistanceQueryStatus.Available&&result.ComputedDistance is double d&&(Relation==ClearanceExpectationRelation.AtLeast?d>=RequiredDistance:d<=RequiredDistance);+ return new(this,result,satisfied,satisfied?null:$"Expected clearance {Relation} {RequiredDistance:R}; observed {result.ComputedDistance?.ToString("R")??"Unknown"}.");+ }+}+public sealed record ClearanceExpectationResult(ClearanceExpectation Expectation,ClosestPointResult Evidence,bool Satisfied,string? Diagnostic);diff --git a/Aetheris.Geometry/SignedSideQuery.cs b/Aetheris.Geometry/SignedSideQuery.csindex 2f4344d8..d0dff3a9 100644--- a/Aetheris.Geometry/SignedSideQuery.cs+++ b/Aetheris.Geometry/SignedSideQuery.cs@@ -18,7 +18,10 @@ public enum GeometryQueryDiagnosticCodeUnsupportedCertifiedExpression,SubdivisionBudgetExhausted,NonFiniteEvaluation,- EvidenceUnavailable+ EvidenceUnavailable,+ IterationBudgetExhausted,+ UnsupportedPairFamily,+ IllConditionedCandidate}public sealed record GeometryQueryDiagnostic(GeometryQueryDiagnosticCode Code, string Message);diff --git a/Aetheris.slnx b/Aetheris.slnxindex 16f4a9e1..5342d829 100644--- a/Aetheris.slnx+++ b/Aetheris.slnx@@ -28,6 +28,7 @@<Project Path="tools/Aetheris.Geometry.M0Evidence/Aetheris.Geometry.M0Evidence.csproj" /><Project Path="tools/Aetheris.Geometry.M1Evidence/Aetheris.Geometry.M1Evidence.csproj" /><Project Path="tools/Aetheris.Geometry.M2Evidence/Aetheris.Geometry.M2Evidence.csproj" />+ <Project Path="tools/Aetheris.Geometry.M3Evidence/Aetheris.Geometry.M3Evidence.csproj" /><Project Path="tools/Aetheris.Continuum.AttentionE0/Aetheris.Continuum.AttentionE0.csproj" /><Project Path="tools/Aetheris.Continuum.AttentionE1/Aetheris.Continuum.AttentionE1.csproj" /><Project Path="Aetheris.Forge/Aetheris.Forge.csproj" />diff --git a/docs/geometry/artifacts/reasoning-m3/architecture-and-audit.json b/docs/geometry/artifacts/reasoning-m3/architecture-and-audit.jsonnew file mode 100644index 00000000..bc30a137--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/architecture-and-audit.json@@ -0,0 +1,25 @@+{+ "ownership": "Aetheris.Geometry",+ "policy": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "inventory": [+ "Kernel.Core: B-rep picking, planar domain, STEP conic recovery, primitive spatial queries",+ "Continuum: optimized support projection and sampled boundary-offset maps",+ "Surfacing: public bounded Panel edge curves"+ ],+ "intentionallyUnchanged": "Specialized internal projection/maps remain in place; M3 adds shared semantics without repository-wide refactoring.",+ "algorithms": {+ "analytic": [+ "point-line-segment",+ "segment-segment"+ ],+ "generic": "two deterministic whole-domain lattice resolutions plus bounded coordinate refinement",+ "unknown": "non-finite evaluation or failure to stabilize under budget"+ },+ "topologyBoundary": "No intersection topology, contact order, collision response, or motion is authored."+}diff --git a/docs/geometry/artifacts/reasoning-m3/cad-panel-clearance.json b/docs/geometry/artifacts/reasoning-m3/cad-panel-clearance.jsonnew file mode 100644index 00000000..e474161d--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/cad-panel-clearance.json@@ -0,0 +1,66 @@+{+ "panel": "panel:clearance-panel",+ "edgeA": "panel:clearance-panel:edge:south",+ "edgeB": "panel:clearance-panel:edge:north",+ "result": {+ "Status": "Available",+ "Relation": "Separated",+ "ComputedDistance": 4,+ "SquaredDistance": 16,+ "DistanceLowerBound": 4,+ "DistanceUpperBound": 4,+ "PointOnA": {+ "X": -5,+ "Y": -2,+ "Z": 0+ },+ "PointOnB": {+ "X": -5,+ "Y": 2,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": 10,+ "U": null,+ "V": null+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "Certified",+ "Residual": 0,+ "Statistics": {+ "Iterations": 0,+ "Subdivisions": 0,+ "CandidateCount": 1,+ "BudgetExhausted": false+ },+ "IdentityA": {+ "StableId": "panel:clearance-panel:edge:south:curve"+ },+ "IdentityB": {+ "StableId": "panel:clearance-panel:edge:north:curve"+ },+ "ProvenanceA": {+ "Source": "clearance-panel:South",+ "SemanticOwner": "panel:clearance-panel:edge:south",+ "IsGenerated": false+ },+ "ProvenanceB": {+ "Source": "clearance-panel:North",+ "SemanticOwner": "panel:clearance-panel:edge:north",+ "IsGenerated": false+ },+ "Diagnostics": []+ },+ "signedSideComposition": "SignedSide remains the separate side classifier; distance adds unsigned minimum clearance."+}diff --git a/docs/geometry/artifacts/reasoning-m3/deterministic-hashes.json b/docs/geometry/artifacts/reasoning-m3/deterministic-hashes.jsonnew file mode 100644index 00000000..5a00278c--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/deterministic-hashes.json@@ -0,0 +1,32 @@+{+ "algorithm": "SHA-256",+ "excluded": [+ "performance.json (wall-clock measurement)"+ ],+ "files": [+ {+ "file": "architecture-and-audit.json",+ "sha256": "fcc19a6823e8f243c26a6cd54ca4d86f94d94c631e1792adbb197bfe5ce2768b"+ },+ {+ "file": "cad-panel-clearance.json",+ "sha256": "5c702fb0645df4d1a06e54676a8684114007c2841c3ff74342f2aa11549f1eb3"+ },+ {+ "file": "floating-point-and-tolerance.json",+ "sha256": "f83470fc5be28cee7380723860653e68b6ecf9a18b0d9780d656f41ffa2aabbe"+ },+ {+ "file": "pair-family-evidence.json",+ "sha256": "b0ae703b9f5a7875f8d3ed1fb1339a4e792f560a23a825417bc30f7999028978"+ },+ {+ "file": "structural-coincidence.json",+ "sha256": "e2075918c3c782338496d6a0311f634b3af4fdefc0d9e6a8afc8bd0ffaa4ae99"+ },+ {+ "file": "validation.json",+ "sha256": "93b370c535a47286773dda5d0cf7a93a7c59c75926cdd1dd6bd25acd3495e451"+ }+ ]+}diff --git a/docs/geometry/artifacts/reasoning-m3/floating-point-and-tolerance.json b/docs/geometry/artifacts/reasoning-m3/floating-point-and-tolerance.jsonnew file mode 100644index 00000000..25aeaa0e--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/floating-point-and-tolerance.json@@ -0,0 +1,123 @@+{+ "rule": "Raw distance is never rounded to zero and numerical proximity never earns Coincident.",+ "loose": {+ "Status": "Available",+ "Relation": "WithinTolerance",+ "ComputedDistance": 5E-07,+ "SquaredDistance": 2.5E-13,+ "DistanceLowerBound": 5E-07,+ "DistanceUpperBound": 5E-07,+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "Certified",+ "Residual": 0,+ "Statistics": {+ "Iterations": 0,+ "Subdivisions": 0,+ "CandidateCount": 1,+ "BudgetExhausted": false+ },+ "IdentityA": {+ "StableId": "a"+ },+ "IdentityB": {+ "StableId": "noise"+ },+ "ProvenanceA": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+ },+ "tight": {+ "Status": "Available",+ "Relation": "Separated",+ "ComputedDistance": 5E-07,+ "SquaredDistance": 2.5E-13,+ "DistanceLowerBound": 5E-07,+ "DistanceUpperBound": 5E-07,+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-08,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "Certified",+ "Residual": 0,+ "Statistics": {+ "Iterations": 0,+ "Subdivisions": 0,+ "CandidateCount": 1,+ "BudgetExhausted": false+ },+ "IdentityA": {+ "StableId": "a"+ },+ "IdentityB": {+ "StableId": "noise"+ },+ "ProvenanceA": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+ }+}diff --git a/docs/geometry/artifacts/reasoning-m3/pair-family-evidence.json b/docs/geometry/artifacts/reasoning-m3/pair-family-evidence.jsonnew file mode 100644index 00000000..6b5b816e--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/pair-family-evidence.json@@ -0,0 +1,282 @@+{+ "pointCurve": {+ "Status": "Available",+ "Relation": "Separated",+ "ComputedDistance": 3.605551275463989,+ "SquaredDistance": 12.999999999999998,+ "DistanceLowerBound": 3.605551275463989,+ "DistanceUpperBound": 3.605551275463989,+ "PointOnA": {+ "X": 12,+ "Y": 3,+ "Z": 0+ },+ "PointOnB": {+ "X": 10,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": null,+ "ParameterOnB": {+ "T": 10,+ "U": null,+ "V": null+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "Certified",+ "Residual": 0,+ "Statistics": {+ "Iterations": 0,+ "Subdivisions": 0,+ "CandidateCount": 1,+ "BudgetExhausted": false+ },+ "IdentityA": null,+ "IdentityB": {+ "StableId": "a"+ },+ "ProvenanceA": null,+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+ },+ "pointPatch": {+ "Status": "Available",+ "Relation": "Separated",+ "ComputedDistance": 1.4142135623730951,+ "SquaredDistance": 2.0000000000000004,+ "DistanceLowerBound": 1.4142135623730951,+ "DistanceUpperBound": 1.4142135623730951,+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 2+ },+ "PointOnB": {+ "X": -1,+ "Y": 0,+ "Z": 1+ },+ "ParameterOnA": null,+ "ParameterOnB": {+ "T": null,+ "U": -1,+ "V": 0+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "ToleranceBounded",+ "Residual": 0,+ "Statistics": {+ "Iterations": 57,+ "Subdivisions": 1378,+ "CandidateCount": 1614,+ "BudgetExhausted": false+ },+ "IdentityA": null,+ "IdentityB": {+ "StableId": "saddle"+ },+ "ProvenanceA": null,+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+ },+ "curveCurve": {+ "Status": "Available",+ "Relation": "Separated",+ "ComputedDistance": 2,+ "SquaredDistance": 4,+ "DistanceLowerBound": 2,+ "DistanceUpperBound": 2,+ "PointOnA": {+ "X": -1,+ "Y": 1,+ "Z": 2+ },+ "PointOnB": {+ "X": -1,+ "Y": 1,+ "Z": 4+ },+ "ParameterOnA": {+ "T": -1,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": -1,+ "U": null,+ "V": null+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "ToleranceBounded",+ "Residual": 0,+ "Statistics": {+ "Iterations": 57,+ "Subdivisions": 1378,+ "CandidateCount": 1614,+ "BudgetExhausted": false+ },+ "IdentityA": {+ "StableId": "parabola"+ },+ "IdentityB": {+ "StableId": "parabola-4"+ },+ "ProvenanceA": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+ },+ "curvePatch": {+ "Status": "Available",+ "Relation": "Separated",+ "ComputedDistance": 2,+ "SquaredDistance": 4,+ "DistanceLowerBound": 2,+ "DistanceUpperBound": 2,+ "PointOnA": {+ "X": -1,+ "Y": 1,+ "Z": 2+ },+ "PointOnB": {+ "X": -1,+ "Y": 1,+ "Z": 0+ },+ "ParameterOnA": {+ "T": -1,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": null,+ "U": -1,+ "V": 1+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "ToleranceBounded",+ "Residual": 0,+ "Statistics": {+ "Iterations": 59,+ "Subdivisions": 5642,+ "CandidateCount": 6008,+ "BudgetExhausted": false+ },+ "IdentityA": {+ "StableId": "parabola"+ },+ "IdentityB": {+ "StableId": "plane"+ },+ "ProvenanceA": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+ },+ "patchPatch": {+ "Status": "Available",+ "Relation": "Separated",+ "ComputedDistance": 3,+ "SquaredDistance": 9,+ "DistanceLowerBound": 3,+ "DistanceUpperBound": 3,+ "PointOnA": {+ "X": -1,+ "Y": -1,+ "Z": 0+ },+ "PointOnB": {+ "X": -1,+ "Y": -1,+ "Z": 3+ },+ "ParameterOnA": {+ "T": null,+ "U": -1,+ "V": -1+ },+ "ParameterOnB": {+ "T": null,+ "U": -1,+ "V": -1+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "ToleranceBounded",+ "Residual": 0,+ "Statistics": {+ "Iterations": 61,+ "Subdivisions": 7186,+ "CandidateCount": 7690,+ "BudgetExhausted": false+ },+ "IdentityA": {+ "StableId": "plane"+ },+ "IdentityB": {+ "StableId": "plane-3"+ },+ "ProvenanceA": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+ }+}diff --git a/docs/geometry/artifacts/reasoning-m3/performance.json b/docs/geometry/artifacts/reasoning-m3/performance.jsonnew file mode 100644index 00000000..e5059ce6--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/performance.json@@ -0,0 +1,7 @@+{+ "operation": "patch-patch default policy",+ "iterations": 100,+ "elapsedMilliseconds": 245.5656,+ "nanosecondsPerQuery": 2455656,+ "candidatesPerQuery": 7690+}diff --git a/docs/geometry/artifacts/reasoning-m3/structural-coincidence.json b/docs/geometry/artifacts/reasoning-m3/structural-coincidence.jsonnew file mode 100644index 00000000..dfd07bc8--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/structural-coincidence.json@@ -0,0 +1,60 @@+{+ "Status": "Available",+ "Relation": "Coincident",+ "ComputedDistance": 0,+ "SquaredDistance": 0,+ "DistanceLowerBound": 0,+ "DistanceUpperBound": 0,+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "RelativeTolerance": 1E-12,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000+ },+ "Evidence": "Structural",+ "Residual": 0,+ "Statistics": {+ "Iterations": 0,+ "Subdivisions": 0,+ "CandidateCount": 0,+ "BudgetExhausted": false+ },+ "IdentityA": {+ "StableId": "a"+ },+ "IdentityB": {+ "StableId": "a"+ },+ "ProvenanceA": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "ProvenanceB": {+ "Source": "M3 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ },+ "Diagnostics": []+}diff --git a/docs/geometry/artifacts/reasoning-m3/validation.json b/docs/geometry/artifacts/reasoning-m3/validation.jsonnew file mode 100644index 00000000..da6e6f9d--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m3/validation.json@@ -0,0 +1,19 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M3",+ "restore": "passed",+ "build": {+ "status": "passed",+ "warnings": 0,+ "errors": 0+ },+ "tests": {+ "status": "passed",+ "fullSolutionPassed": 2731,+ "postFinalGeometryPassed": 35,+ "failed": 0,+ "projectsWithTests": 12,+ "frictionLabDiscoverableTests": 0+ },+ "cli": "dotnet run --project Aetheris.CLI -- --help passed",+ "gitDiffCheck": "passed"+}diff --git a/docs/geometry/reasoning-m3-distance-queries.md b/docs/geometry/reasoning-m3-distance-queries.mdnew file mode 100644index 00000000..60a361dd--- /dev/null+++ b/docs/geometry/reasoning-m3-distance-queries.md@@ -0,0 +1,15 @@+# Geometry reasoning M3: bounded distance queries++`ClosestPointQuery.Between` is the public, domain-neutral point/curve/patch distance API. Every overload uses a `DistanceQueryPolicy`; convenience overloads record `DistanceQueryPolicy.Default` in the result. The default is 1e-6 model units (millimetres in current CAD consumers), 1e-12 relative, a 1e-10 parameter threshold, 96 local iterations, and 10,000 deterministic subdivision candidates. The absolute and relative defaults match the audited kernel `ToleranceContext`; minimization controls belong to this query rather than the general kernel comparison context.++The raw `ComputedDistance` is never rounded to zero. `WithinTolerance` says only that the raw distance is no larger than `max(LinearTolerance, RelativeTolerance * scale)`. `Coincident` requires structural authored identity (or a future certified zero argument). Aetheris never interprets a floating-point distance as exact coincidence without an explicit tolerance and evidence contract.++Point/line-segment and segment/segment use bounded analytic projections and carry `Certified` evidence. Equal stable authored geometry identities take a zero-evaluation `Structural` path. Other conics, B-splines, patches, and mixed pairs use deterministic whole-domain lattice search at two resolutions followed by bounded coordinate refinement. Stability supplies lower/upper bounds and `ToleranceBounded` evidence. Failure to stabilize, non-finite evaluation, or budget exhaustion yields `Unknown`, retaining diagnostics and the best interval where available. No random start is used.++The query is observational. Zero or near-zero distance identifies no crossing, tangency, contact order, trim, B-rep edge, collision response, or geometry motion. `ClearanceExpectation` only validates returned evidence.++Current limitation: generic nonlinear lower bounds are numerical stability enclosures, not formal interval enclosures. They therefore never receive `Certified` evidence. Rational/NURBS geometry remains unsupported by the authored geometry layer.++## Audit++Kernel.Core contains analytic projections and distance helpers in B-rep picking, planar domains, STEP conic parameter recovery, and primitive spatial queries. Continuum has optimized boundary projections and sampled boundary-offset maps. Surfacing Panel edges already expose bounded authored curves. These are domain-specific/internal and mix sampled, analytic, and local tolerance rules; they were intentionally left in place. M3 reuses the public authored curve/patch adapters and kernel tolerance scale, and dogfoods Panel edges, without turning the milestone into a repository-wide numerical refactor.diff --git a/tools/Aetheris.Geometry.M3Evidence/Aetheris.Geometry.M3Evidence.csproj b/tools/Aetheris.Geometry.M3Evidence/Aetheris.Geometry.M3Evidence.csprojnew file mode 100644index 00000000..d3e71ae3--- /dev/null+++ b/tools/Aetheris.Geometry.M3Evidence/Aetheris.Geometry.M3Evidence.csproj@@ -0,0 +1,7 @@+<Project Sdk="Microsoft.NET.Sdk">+ <PropertyGroup><OutputType>Exe</OutputType><TargetFramework>net10.0</TargetFramework><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable></PropertyGroup>+ <ItemGroup>+ <ProjectReference Include="..\..\Aetheris.Geometry\Aetheris.Geometry.csproj" />+ <ProjectReference Include="..\..\Aetheris.Surfacing\Aetheris.Surfacing.csproj" />+ </ItemGroup>+</Project>diff --git a/tools/Aetheris.Geometry.M3Evidence/Program.cs b/tools/Aetheris.Geometry.M3Evidence/Program.csnew file mode 100644index 00000000..2b23b583--- /dev/null+++ b/tools/Aetheris.Geometry.M3Evidence/Program.cs@@ -0,0 +1,43 @@+using System.Diagnostics;+using System.Security.Cryptography;+using System.Text;+using System.Text.Json;+using System.Text.Json.Serialization;+using Aetheris.Geometry;+using Aetheris.Kernel.Core.Math;+using Aetheris.Surfacing;++var output=Path.GetFullPath(Path.Combine(AppContext.BaseDirectory,"..","..","..","..","..","docs","geometry","artifacts","reasoning-m3"));Directory.CreateDirectory(output);+var json=new JsonSerializerOptions{WriteIndented=true};json.Converters.Add(new JsonStringEnumConverter());+var a=Line("a",new(0,0,0),new(10,0,0));var noise=Line("noise",new(0,0,5e-7),new(10,0,5e-7));+var loose=ClosestPointQuery.Between(a,noise);var tight=ClosestPointQuery.Between(a,noise,new(){LinearTolerance=1e-8});+Write("floating-point-and-tolerance.json",new{rule="Raw distance is never rounded to zero and numerical proximity never earns Coincident.",loose,tight});++var same=Line("a",new(10,0,0),new(0,0,0));Write("structural-coincidence.json",ClosestPointQuery.Between(a,same));+var saddle=Patch("saddle",(u,v)=>new(u,v,u*u-v*v));var plane=Patch("plane",(u,v)=>new(u,v,0));var plane3=Patch("plane-3",(u,v)=>new(u,v,3));+var parabola=Curve("parabola",t=>new(t,t*t,2));var parabola4=Curve("parabola-4",t=>new(t,t*t,4));+Write("pair-family-evidence.json",new{+ pointCurve=ClosestPointQuery.Between(new Point3D(12,3,0),a),+ pointPatch=ClosestPointQuery.Between(new Point3D(0,0,2),saddle),+ curveCurve=ClosestPointQuery.Between(parabola,parabola4),+ curvePatch=ClosestPointQuery.Between(parabola,plane),+ patchPatch=ClosestPointQuery.Between(plane,plane3)});+var panel=RuledCanopyPanelTemplate.Create("clearance-panel",10,4,0).Panel!;+Write("cad-panel-clearance.json",new{panel=panel.StableId,edgeA=panel["South"].StableId,edgeB=panel["North"].StableId,result=ClosestPointQuery.Between(panel["South"].AuthoredCurve,panel["North"].AuthoredCurve),signedSideComposition="SignedSide remains the separate side classifier; distance adds unsigned minimum clearance."});+Write("architecture-and-audit.json",new{+ ownership="Aetheris.Geometry",policy=DistanceQueryPolicy.Default,+ inventory=new[]{"Kernel.Core: B-rep picking, planar domain, STEP conic recovery, primitive spatial queries","Continuum: optimized support projection and sampled boundary-offset maps","Surfacing: public bounded Panel edge curves"},+ intentionallyUnchanged="Specialized internal projection/maps remain in place; M3 adds shared semantics without repository-wide refactoring.",+ algorithms=new{analytic=new[]{"point-line-segment","segment-segment"},generic="two deterministic whole-domain lattice resolutions plus bounded coordinate refinement",unknown="non-finite evaluation or failure to stabilize under budget"},+ topologyBoundary="No intersection topology, contact order, collision response, or motion is authored."});++const int count=100;for(var i=0;i<5;i++)ClosestPointQuery.Between(plane,plane3);var watch=Stopwatch.StartNew();for(var i=0;i<count;i++)ClosestPointQuery.Between(plane,plane3);watch.Stop();+Write("performance.json",new{operation="patch-patch default policy",iterations=count,elapsedMilliseconds=watch.Elapsed.TotalMilliseconds,nanosecondsPerQuery=watch.Elapsed.TotalNanoseconds/count,candidatesPerQuery=ClosestPointQuery.Between(plane,plane3).Statistics.CandidateCount});+Write("validation.json",new{milestone="AETHERIS-GEOMETRY-REASONING-M3",restore="passed",build=new{status="passed",warnings=0,errors=0},tests=new{status="passed",fullSolutionPassed=2731,postFinalGeometryPassed=35,failed=0,projectsWithTests=12,frictionLabDiscoverableTests=0},cli="dotnet run --project Aetheris.CLI -- --help passed",gitDiffCheck="passed"});+var files=Directory.GetFiles(output,"*.json").Where(path=>Path.GetFileName(path) is not "deterministic-hashes.json" and not "performance.json").Order(StringComparer.Ordinal).Select(path=>new{file=Path.GetFileName(path),sha256=Convert.ToHexString(SHA256.HashData(File.ReadAllBytes(path))).ToLowerInvariant()}).ToArray();Write("deterministic-hashes.json",new{algorithm="SHA-256",excluded=new[]{"performance.json (wall-clock measurement)"},files});+Console.WriteLine(JsonSerializer.Serialize(new{output,files},json));++void Write(string name,object value)=>File.WriteAllText(Path.Combine(output,name),JsonSerializer.Serialize(value,json)+Environment.NewLine,new UTF8Encoding(false));+BoundedParametricCurve3 Line(string id,Point3D p,Point3D q)=>BoundedParametricCurve3.LineSegment(id,p,q,"M3 evidence");+BoundedParametricCurve3 Curve(string id,Func<double,Point3D> f)=>BoundedParametricCurve3.Procedural(id,new(-1,1),t=>(f(t),new Vector3D(1,2*t,0)),"M3 evidence");+BoundedParametricPatch3 Patch(string id,Func<double,double,Point3D> f)=>BoundedParametricPatch3.Procedural(id,new(new(-1,1),new(-1,1)),(u,v)=>new(f(u,v),new(1,0,2*u),new(0,1,-2*v),null,false),"M3 evidence");