Next Gen STEP AP242 Native-ish BREP Geometric Modeling Kernel
Document M4 intersection reasoning milestone
Yuechen Li70b18c002655
diff --git a/Aetheris.Geometry.Tests/IntersectionQueryTests.cs b/Aetheris.Geometry.Tests/IntersectionQueryTests.csnew file mode 100644index 00000000..f40a9d07--- /dev/null+++ b/Aetheris.Geometry.Tests/IntersectionQueryTests.cs@@ -0,0 +1,184 @@+using System.Security.Cryptography;+using System.Text;+using System.Text.Json;+using Aetheris.Geometry;+using Aetheris.Kernel.Core.Brep;+using Aetheris.Kernel.Core.Geometry;+using Aetheris.Kernel.Core.Geometry.Surfaces;+using Aetheris.Kernel.Core.Math;+using Aetheris.Surfacing;+using Xunit;++namespace Aetheris.Geometry.Tests;++public sealed class IntersectionQueryTests+{+ private static readonly Plane3 Z0 = new(Point3D.Origin, Direction3D.Create(new(0, 0, 1)));++ [Fact]+ public void Curve_plane_reports_certified_disjoint_crossing_and_structural_zero()+ {+ var disjoint = IntersectionQuery.Between(Line("above", new(-1, 0, 2), new(1, 0, 2)), Z0);+ var crossing = IntersectionQuery.Between(Line("crossing", new(0, 0, -1), new(0, 0, 1)), Z0);+ var zero = IntersectionQuery.Between(Line("zero", new(-1, 0, 0), new(1, 0, 0)), Z0);++ Assert.Equal((IntersectionRelation.Disjoint, PredicateEvidenceKind.Certified), (disjoint.Relation, disjoint.Evidence));+ Assert.Equal((IntersectionRelation.Crossing, PredicateEvidenceKind.Certified), (crossing.Relation, crossing.Evidence));+ Assert.Equal((IntersectionRelation.Coincident, PredicateEvidenceKind.Structural), (zero.Relation, zero.Evidence));+ Assert.True(disjoint.IsDefinitelyDisjoint); Assert.Single(crossing.WitnessPoints);+ }++ [Fact]+ public void Curve_plane_tangent_needs_global_one_sided_and_second_order_evidence()+ {+ var t = CurveExpression.T; var square = CurveExpression.Multiply(CurveExpression.Length(1), CurveExpression.Power(t, 2));+ var parabola = new BoundedParametricCurve3("parabola", new(-1, 1),+ new(CurveExpression.Multiply(CurveExpression.Length(1), t), CurveExpression.Length(0), square), "fixture");+ var result = IntersectionQuery.Between(parabola, Z0, new() { LinearTolerance = 1e-9 });+ Assert.Equal(IntersectionRelation.Touching, result.Relation); Assert.Equal(PredicateEvidenceKind.ToleranceBounded, result.Evidence);+ Assert.Equal(IntersectionLocalRelation.TouchingCandidate, Assert.Single(result.WitnessPoints).LocalRelation);+ Assert.True(result.WitnessPoints[0].Contact!.HasSecondJet);++ var localOnly = BoundedParametricCurve3.Procedural("local-only", new(-1, 1), x =>+ (new(x, 0, x * x), new Vector3D(1, 0, 2 * x)), "fixture");+ var unknown = IntersectionQuery.Between(localOnly, Z0);+ Assert.Equal(IntersectionRelation.Unknown, unknown.Relation);+ Assert.Contains(unknown.Diagnostics, d => d.Code == GeometryQueryDiagnosticCode.InsufficientSecondJetEvidence);+ }++ [Fact]+ public void Patch_plane_reuses_signed_side_and_is_conservative_about_tangency()+ {+ var above = Graph("above", SurfaceExpression.Length(2));+ var saddle = Graph("saddle", SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.U));+ var squared = SurfaceExpression.Add(+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.Power(SurfaceExpression.U, 2)),+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.Power(SurfaceExpression.V, 2)));+ var tangent = Graph("paraboloid", squared);+ Assert.Equal(IntersectionRelation.Disjoint, IntersectionQuery.Between(above, Z0).Relation);+ Assert.Equal(IntersectionRelation.Crossing, IntersectionQuery.Between(saddle, Z0).Relation);+ var contact = IntersectionQuery.Between(tangent, Z0);+ Assert.Equal(IntersectionRelation.Touching, contact.Relation); Assert.Equal(PredicateEvidenceKind.ToleranceBounded, contact.Evidence);++ var sampled = IntersectionQuery.Between(above, Z0, new() { EvidencePreference = IntersectionEvidencePreference.AllowSampled });+ Assert.Equal(PredicateEvidenceKind.Sampled, sampled.Evidence); Assert.NotEqual(PredicateEvidenceKind.Certified, sampled.Evidence);+ }++ [Fact]+ public void Curve_patch_uses_distance_gate_then_local_transversality()+ {+ var patch = PlanePatch("panel", 0);+ var separated = IntersectionQuery.Between(Line("gap", new(-.5, 0, 2), new(.5, 0, 2)), patch);+ var crossing = IntersectionQuery.Between(Line("pierce", new(0, 0, -1), new(0, 0, 1)), patch);+ var tangent = IntersectionQuery.Between(Line("tangent", new(-.5, 0, 0), new(.5, 0, 0)), patch);+ Assert.Equal(IntersectionRelation.Disjoint, separated.Relation);+ Assert.Equal(IntersectionRelation.Crossing, crossing.Relation);+ Assert.Equal(IntersectionRelation.Unknown, tangent.Relation);+ Assert.Equal(IntersectionLocalRelation.TouchingCandidate, Assert.Single(tangent.WitnessPoints).LocalRelation);+ Assert.False(tangent.WitnessesAreAuthoritativeTrims);+ }++ [Fact]+ public void Curve_patch_budget_exhaustion_is_typed_unknown()+ {+ var result = IntersectionQuery.Between(Line("curve", new(0, 0, -1), new(0, 0, 1)), PlanePatch("patch", 0), new() { SubdivisionBudget = 16 });+ Assert.Equal(IntersectionRelation.Unknown, result.Relation); Assert.True(result.Statistics.BudgetExhausted);+ Assert.Contains(result.Diagnostics, d => d.Code == GeometryQueryDiagnosticCode.SubdivisionBudgetExhausted);+ }++ [Fact]+ public void Patch_patch_distinguishes_gap_transverse_contact_and_identity()+ {+ var a = PlanePatch("a", 0); var gap = PlanePatch("gap", 2);+ var transverse = VerticalPatch("vertical"); var tangent = PlanePatch("tangent", 0);+ var sameIdentity = PlanePatch("a", 0);+ Assert.Equal(IntersectionRelation.Disjoint, IntersectionQuery.Between(a, gap).Relation);+ var transverseResult = IntersectionQuery.Between(a, transverse);+ Assert.Equal(IntersectionRelation.Crossing, transverseResult.Relation);+ Assert.True(transverseResult.WitnessPoints.Count > 1);+ var tangentResult = IntersectionQuery.Between(a, tangent);+ Assert.Equal(IntersectionRelation.Unknown, tangentResult.Relation);+ Assert.NotEmpty(tangentResult.WitnessPoints);+ Assert.All(tangentResult.WitnessPoints, witness => Assert.Equal(IntersectionLocalRelation.TouchingCandidate, witness.LocalRelation));+ var coincidence = IntersectionQuery.Between(a, sameIdentity);+ Assert.Equal((IntersectionRelation.Coincident, PredicateEvidenceKind.Structural), (coincidence.Relation, coincidence.Evidence));+ }++ [Fact]+ public void Numerical_near_zero_never_becomes_structural_overlap_or_a_bool_only_claim()+ {+ var a = PlanePatch("a", 0); var near = PlanePatch("near", 5e-7);+ var result = IntersectionQuery.Between(a, near);+ Assert.NotEqual(IntersectionRelation.Coincident, result.Relation);+ Assert.NotEqual(IntersectionRelation.Overlapping, result.Relation);+ Assert.Equal(IntersectionRelation.Unknown, result.Relation);+ Assert.False(result.IsDefinitelyDisjoint);++ var nearLine = IntersectionQuery.Between(Line("near-line", new(-1, 0, 5e-7), new(1, 0, 5e-7)), Z0);+ Assert.NotEqual(IntersectionRelation.Coincident, nearLine.Relation);+ Assert.NotEqual(PredicateEvidenceKind.Structural, nearLine.Evidence);++ var subdomain = BoundedParametricPatch3.Procedural("a", new(new(-.5, .5), new(-.5, .5)),+ (u, v) => new(new(u, v, 0), new(1, 0, 0), new(0, 1, 0), Direction3D.Create(new(0, 0, 1)), false), "fixture");+ var sharedSupportDifferentDomain = IntersectionQuery.Between(a, subdomain);+ Assert.Equal(IntersectionRelation.Unknown, sharedSupportDifferentDomain.Relation);+ Assert.Contains(sharedSupportDifferentDomain.Diagnostics, d => d.Code == GeometryQueryDiagnosticCode.AmbiguousOverlap);+ }++ [Fact]+ public void Panel_plane_and_panel_panel_dogfood_use_authored_patches()+ {+ var surface = new ParametricSurfaceIr("panel", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), GraphExpression(SurfaceExpression.Length(3)), "cad:panel");+ var panel = PanelFactory.FromParametric(surface).Panel!;+ var tooling = IntersectionQuery.Between(panel.AuthoredPatch, Z0);+ var other = PanelFactory.FromParametric(new ParametricSurfaceIr("panel-gap", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), GraphExpression(SurfaceExpression.Length(5)), "cad:panel-gap")).Panel!;+ var gap = IntersectionQuery.Between(panel.AuthoredPatch, other.AuthoredPatch);+ Assert.Equal(IntersectionRelation.Disjoint, tooling.Relation); Assert.Equal(IntersectionRelation.Disjoint, gap.Relation);+ Assert.Equal("cad:panel", tooling.OperandA.Provenance!.Source);+ }++ [Fact]+ public void Generic_query_cannot_mutate_or_materialize_brep_topology()+ {+ var body = BrepPrimitives.CreateBox(4, 6, 8).Value;+ var before = (Vertices: body.Topology.Vertices.Count(), Edges: body.Topology.Edges.Count(), Faces: body.Topology.Faces.Count(), Curves: body.Geometry.Curves.Count(), Surfaces: body.Geometry.Surfaces.Count());+ var result = IntersectionQuery.Between(Line("query", new(0, 0, -1), new(0, 0, 1)), PlanePatch("patch", 0));+ var after = (Vertices: body.Topology.Vertices.Count(), Edges: body.Topology.Edges.Count(), Faces: body.Topology.Faces.Count(), Curves: body.Geometry.Curves.Count(), Surfaces: body.Geometry.Surfaces.Count());+ Assert.Equal(before, after); Assert.Equal(IntersectionRelation.Crossing, result.Relation);+ Assert.False(result.WitnessesAreAuthoritativeTrims);+ Assert.DoesNotContain(result.GetType().GetProperties(), p => p.PropertyType == typeof(BrepBody));+ }++ [Fact]+ public void Constructive_cone_plane_hyperbola_remains_a_separate_materializer()+ {+ var cone = new ConeSurface(Point3D.Origin, Direction3D.Create(new(1, 0, 0)), double.Pi / 4, Direction3D.Create(new(0, 0, 1)));+ var construction = TransverseConePlaneIntersection.IntersectWorldZ(cone, 2);+ Assert.True(construction.IsSuccess); Assert.Equal("Hyperbola3Curve", construction.Value.GetType().Name);+ }++ [Fact]+ public void Results_and_witness_order_are_deterministic()+ {+ var a = PlanePatch("horizontal", 0); var b = VerticalPatch("vertical");+ var first = JsonSerializer.Serialize(IntersectionQuery.Between(a, b));+ var second = JsonSerializer.Serialize(IntersectionQuery.Between(a, b));+ Assert.Equal(first, second);+ var hash1 = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(first)));+ var hash2 = Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(second)));+ Assert.Equal(hash1, hash2);+ }++ private static BoundedParametricCurve3 Line(string id, Point3D a, Point3D b) => BoundedParametricCurve3.LineSegment(id, a, b, "fixture");+ private static BoundedParametricPatch3 Graph(string id, SurfaceScalarExpression z) => new(id, new(new(-1, 1), new(-1, 1)), GraphExpression(z), "fixture:" + id);+ private static SurfacePointExpression GraphExpression(SurfaceScalarExpression z) => new(+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.U),+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.V), z);+ private static BoundedParametricPatch3 PlanePatch(string id, double z) => BoundedParametricPatch3.Procedural(id,+ new(new(-1, 1), new(-1, 1)), (u, v) => new(new(u, v, z), new(1, 0, 0), new(0, 1, 0), Direction3D.Create(new(0, 0, 1)), false),+ (u, v) => new(new(u, v, z), new(1, 0, 0), new(0, 1, 0), new(0, 0, 0), new(0, 0, 0), new(0, 0, 0), DifferentialSingularityKind.Regular), "fixture");+ private static BoundedParametricPatch3 VerticalPatch(string id) => BoundedParametricPatch3.Procedural(id,+ new(new(-1, 1), new(-1, 1)), (u, v) => new(new(u, 0, v), new(1, 0, 0), new(0, 0, 1), Direction3D.Create(new(0, -1, 0)), false), "fixture");+}diff --git a/Aetheris.Geometry/IntersectionQuery.cs b/Aetheris.Geometry/IntersectionQuery.csnew file mode 100644index 00000000..63a0fa14--- /dev/null+++ b/Aetheris.Geometry/IntersectionQuery.cs@@ -0,0 +1,495 @@+using Aetheris.Kernel.Core.Math;+using Aetheris.Kernel.Core.Numerics;++namespace Aetheris.Geometry;++/// <summary>The strongest whole-domain relation justified by a bounded observational query.</summary>+public enum IntersectionRelation { Disjoint, Crossing, Touching, Coincident, Overlapping, Unknown }+public enum IntersectionEvidencePreference { PreferCertified, AllowToleranceBounded, AllowSampled }+public enum IntersectionLocalRelation { Crossing, TouchingCandidate, CoincidentCandidate, Unclassified }++public sealed record IntersectionPolicy+{+ public static IntersectionPolicy Default { get; } = new();+ public double LinearTolerance { get; init; } = ToleranceContext.Default.Linear;+ public double AngularTolerance { get; init; } = ToleranceContext.Default.Angular;+ public double ParameterTolerance { get; init; } = 1e-10;+ public int IterationBudget { get; init; } = 96;+ public int SubdivisionBudget { get; init; } = 10_000;+ public IntersectionEvidencePreference EvidencePreference { get; init; } = IntersectionEvidencePreference.PreferCertified;++ public IntersectionPolicy Validate()+ {+ Positive(LinearTolerance, nameof(LinearTolerance)); Positive(AngularTolerance, nameof(AngularTolerance));+ Positive(ParameterTolerance, nameof(ParameterTolerance));+ if (IterationBudget < 1) throw new ArgumentOutOfRangeException(nameof(IterationBudget));+ if (SubdivisionBudget < 16) throw new ArgumentOutOfRangeException(nameof(SubdivisionBudget));+ return this;+ }++ internal DistanceQueryPolicy DistancePolicy => new()+ {+ LinearTolerance = LinearTolerance, ParameterTolerance = ParameterTolerance,+ IterationBudget = IterationBudget, SubdivisionBudget = SubdivisionBudget+ };++ private static void Positive(double value, string name)+ { if (!double.IsFinite(value) || value <= 0d) throw new ArgumentOutOfRangeException(name); }+}++public sealed record IntersectionParameters(double? T = null, double? U = null, double? V = null);+public sealed record IntersectionDomain(string Kind, double? MinimumA, double? MaximumA, double? MinimumB = null, double? MaximumB = null);+public sealed record IntersectionOperand(string Kind, GeometryIdentity? Identity, GeometryProvenance? Provenance);+public sealed record ContactObservation(+ double? TangentNormalDot,+ double? NormalNormalDot,+ double? SignedSecondDerivative,+ bool HasSecondJet,+ string Summary);++/// <summary>A point observation only. It carries no trim, edge, face, or model-authoring authority.</summary>+public sealed record IntersectionWitness(+ Point3D Point,+ Point3D PointOnA,+ Point3D PointOnB,+ IntersectionParameters? ParameterOnA,+ IntersectionParameters? ParameterOnB,+ double Residual,+ IntersectionLocalRelation LocalRelation,+ ContactObservation? Contact);++public sealed record IntersectionStatistics(+ int Samples,+ int Subdivisions,+ int Iterations,+ int ClosestPointCalls,+ int CandidateRegions,+ bool BudgetExhausted);++/// <summary>+/// Immutable evidence about two bounded operands. Witnesses are non-authoritative and non-exportable+/// as trims; this result contains no topology or construction operation.+/// </summary>+public sealed record IntersectionResult(+ IntersectionRelation Relation,+ PredicateEvidenceKind Evidence,+ IntersectionPolicy ToleranceUsed,+ IReadOnlyList<IntersectionWitness> WitnessPoints,+ IReadOnlyList<double> Residuals,+ IntersectionDomain DomainA,+ IntersectionDomain DomainB,+ IntersectionStatistics Statistics,+ IntersectionOperand OperandA,+ IntersectionOperand OperandB,+ string Provenance,+ IReadOnlyList<GeometryQueryDiagnostic> Diagnostics)+{+ public bool IsDefinitelyDisjoint => Relation == IntersectionRelation.Disjoint && Evidence is PredicateEvidenceKind.Structural or PredicateEvidenceKind.Certified or PredicateEvidenceKind.ToleranceBounded;+ public bool WitnessesAreAuthoritativeTrims => false;+}++/// <summary>+/// Bounded intersection predicates. Generic numerical intersection may establish geometric evidence,+/// but it does not author semantic topology.+/// </summary>+public static class IntersectionQuery+{+ public static IntersectionResult Between(BoundedParametricCurve3 curve, Plane3 plane) => Between(curve, plane, IntersectionPolicy.Default);+ public static IntersectionResult Between(BoundedParametricCurve3 curve, Plane3 plane, IntersectionPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(curve); policy.Validate();+ if (!Valid(plane)) return Unknown(curve, plane, policy, [new(GeometryQueryDiagnosticCode.InvalidPlane, "Plane normal must be finite and non-zero.")]);++ var samples = SampleCurvePlane(curve, plane, policy, out var diagnostics);+ if (samples.Count == 0) return Unknown(curve, plane, policy, diagnostics);+ var positive = samples.Where(x => x.Distance > policy.LinearTolerance).ToArray();+ var negative = samples.Where(x => x.Distance < -policy.LinearTolerance).ToArray();+ var contacts = samples.Where(x => double.Abs(x.Distance) <= policy.LinearTolerance).ToArray();+ var analyticLine = curve.NativeFamily == "Line3";++ if (analyticLine)+ {+ var first = samples[0]; var last = samples[^1];+ if (first.Distance == 0d && last.Distance == 0d)+ return Result(IntersectionRelation.Coincident, PredicateEvidenceKind.Structural, policy,+ [Witness(curve, plane, first, IntersectionLocalRelation.CoincidentCandidate, null)], curve, plane,+ new(samples.Count, 0, 0, 0, 1, false), diagnostics, "analytic-line/plane structural zero over bounded segment");+ if (SameStrictSign(first.Distance, last.Distance, policy.LinearTolerance))+ return Result(IntersectionRelation.Disjoint, PredicateEvidenceKind.Certified, policy, [], curve, plane,+ new(samples.Count, 0, 0, 0, 0, false), diagnostics, "affine signed scalar has strict bounded endpoint separation");+ }++ if (positive.Length > 0 && negative.Length > 0)+ {+ var bracket = FirstBracket(samples, policy.LinearTolerance);+ var roots = AllRoots(curve, plane, samples, policy);+ var root = roots.FirstOrDefault();+ var evidence = analyticLine ? PredicateEvidenceKind.Certified : PredicateEvidenceKind.ToleranceBounded;+ return Result(IntersectionRelation.Crossing, evidence, policy,+ roots.Select(x => Witness(curve, plane, x, IntersectionLocalRelation.Crossing, CurvePlaneObservation(curve, plane, x.T, policy))).ToArray(), curve, plane,+ new(samples.Count, 0, bracket is null ? 0 : policy.IterationBudget, 0, roots.Count, false), diagnostics,+ "continuous signed scalar has opposite strict-side witnesses");+ }++ if (TryCurveScalarRange(curve, plane, out var range) && (range.Lower > policy.LinearTolerance || range.Upper < -policy.LinearTolerance))+ return Result(IntersectionRelation.Disjoint, PredicateEvidenceKind.Certified, policy, [], curve, plane,+ new(samples.Count, 1, 0, 0, 0, false), diagnostics, "interval signed scalar proves strict separation");++ if (contacts.Length > 0)+ {+ var contact = contacts.OrderBy(x => double.Abs(x.Distance)).ThenBy(x => x.T).First();+ var observation = CurvePlaneObservation(curve, plane, contact.T, policy);+ var globallyOneSided = TryCurveScalarRange(curve, plane, out range)+ && (range.Lower >= -policy.LinearTolerance || range.Upper <= policy.LinearTolerance);+ if (observation.HasSecondJet && double.Abs(observation.TangentNormalDot ?? 1d) <= policy.AngularTolerance+ && double.Abs(observation.SignedSecondDerivative ?? 0d) > policy.LinearTolerance && globallyOneSided)+ return Result(IntersectionRelation.Touching, PredicateEvidenceKind.ToleranceBounded, policy,+ [Witness(curve, plane, contact, IntersectionLocalRelation.TouchingCandidate, observation)], curve, plane,+ new(samples.Count, 1, 0, 0, 1, false), diagnostics, "whole-domain one-sided interval plus isolated second-order tangent contact");+ diagnostics.Add(new(GeometryQueryDiagnosticCode.InsufficientSecondJetEvidence,+ "A local contact candidate does not establish a whole-domain touching relation."));+ return Result(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, policy,+ [Witness(curve, plane, contact, IntersectionLocalRelation.TouchingCandidate, observation)], curve, plane,+ new(samples.Count, 1, 0, 0, 1, false), diagnostics, "local curve/plane contact remains globally inconclusive");+ }++ return Result(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, policy, [], curve, plane,+ new(samples.Count, 1, 0, 0, 0, false), diagnostics, "bounded samples and intervals were inconclusive");+ }++ public static IntersectionResult Between(Plane3 plane, BoundedParametricCurve3 curve) => Swap(Between(curve, plane));+ public static IntersectionResult Between(Plane3 plane, BoundedParametricCurve3 curve, IntersectionPolicy policy) => Swap(Between(curve, plane, policy));++ public static IntersectionResult Between(BoundedParametricPatch3 patch, Plane3 plane) => Between(patch, plane, IntersectionPolicy.Default);+ public static IntersectionResult Between(BoundedParametricPatch3 patch, Plane3 plane, IntersectionPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(patch); policy.Validate();+ if (!Valid(plane)) return Unknown(patch, plane, policy, [new(GeometryQueryDiagnosticCode.InvalidPlane, "Plane normal must be finite and non-zero.")]);+ var signedPolicy = policy.EvidencePreference == IntersectionEvidencePreference.AllowSampled+ ? SignedSidePolicy.Sampled(policy.LinearTolerance, Samples(policy.SubdivisionBudget), Samples(policy.SubdivisionBudget))+ : SignedSidePolicy.Certified(policy.LinearTolerance, MaxDepth(policy.SubdivisionBudget), policy.SubdivisionBudget);+ var side = SignedSideQuery.Query(patch, plane, signedPolicy);+ var statistics = new IntersectionStatistics(side.Statistics.SampleCount, side.Statistics.LeafCount, 0, 0, side.Witnesses.Count, side.Diagnostics.Any(d => d.Code == GeometryQueryDiagnosticCode.SubdivisionBudgetExhausted));+ if (side.Classification is SignedSideClassification.Positive or SignedSideClassification.Negative)+ return Result(IntersectionRelation.Disjoint, side.EvidenceKind, policy, [], patch, plane, statistics, side.Diagnostics, "SignedSide whole-domain strict-side result");+ if (side.Classification == SignedSideClassification.Crossing)+ return Result(IntersectionRelation.Crossing, side.EvidenceKind, policy,+ side.Witnesses.Select(w => Witness(patch, plane, w, IntersectionLocalRelation.Crossing, null)).ToArray(), patch, plane, statistics, side.Diagnostics,+ "SignedSide opposite-side bounded witnesses establish crossing");++ var diagnostics = side.Diagnostics.ToList();+ if (TryPatchScalarRange(patch, plane, out var range))+ {+ var candidate = PatchPlaneCandidates(patch, plane, policy).FirstOrDefault();+ if (candidate is not null)+ {+ var contact = PatchPlaneObservation(patch, plane, candidate.U, candidate.V, policy);+ var oneSided = range.Lower >= -policy.LinearTolerance || range.Upper <= policy.LinearTolerance;+ if (oneSided && contact.NormalNormalDot is double alignment && 1d - double.Abs(alignment) <= policy.AngularTolerance)+ return Result(IntersectionRelation.Touching, PredicateEvidenceKind.ToleranceBounded, policy,+ [Witness(patch, plane, candidate, IntersectionLocalRelation.TouchingCandidate, contact)], patch, plane, statistics with { CandidateRegions = 1 }, diagnostics,+ "SignedSide-backed whole-domain one-sided interval plus tangent-plane contact");+ }+ }+ diagnostics.Add(new(GeometryQueryDiagnosticCode.InsufficientSecondJetEvidence, "SignedSide did not establish a strict side or crossing; local contact evidence is not a global touching proof."));+ return Result(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, policy, [], patch, plane, statistics, diagnostics, "patch/plane relation remains inconclusive");+ }++ public static IntersectionResult Between(Plane3 plane, BoundedParametricPatch3 patch) => Swap(Between(patch, plane));+ public static IntersectionResult Between(Plane3 plane, BoundedParametricPatch3 patch, IntersectionPolicy policy) => Swap(Between(patch, plane, policy));++ public static IntersectionResult Between(BoundedParametricCurve3 curve, BoundedParametricPatch3 patch) => Between(curve, patch, IntersectionPolicy.Default);+ public static IntersectionResult Between(BoundedParametricCurve3 curve, BoundedParametricPatch3 patch, IntersectionPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(curve); ArgumentNullException.ThrowIfNull(patch); policy.Validate();+ var closest = ClosestPointQuery.Between(curve, patch, policy.DistancePolicy);+ if (closest.Status == DistanceQueryStatus.Unknown) return FromUnknown(closest, curve, patch, policy);+ if (closest.Relation == DistanceRelation.Separated)+ return FromClosest(IntersectionRelation.Disjoint, closest.Evidence, closest, curve, patch, policy, [], "M3 distance gate proves bounded separation");+ var witness = CurvePatchWitness(curve, patch, closest, policy);+ var discovered = FindInteriorCurvePatchWitnesses(curve, patch, policy);+ if (witness is null || witness.LocalRelation != IntersectionLocalRelation.Crossing+ || !Interior(curve, witness.ParameterOnA!.T!.Value, policy.ParameterTolerance)+ || !Interior(patch, witness.ParameterOnB!.U!.Value, witness.ParameterOnB.V!.Value, policy.ParameterTolerance))+ witness = discovered.FirstOrDefault() ?? witness;+ if (witness is null) return FromClosest(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, closest, curve, patch, policy, closest.Diagnostics, "near-zero distance lacks a regular differential candidate");+ var witnesses = Merge(witness, discovered, policy.LinearTolerance);+ if (witnesses.Select(x => x.LocalRelation).Distinct().Count() > 1)+ return FromClosest(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, closest, curve, patch, policy,+ closest.Diagnostics.Concat([new GeometryQueryDiagnostic(GeometryQueryDiagnosticCode.ConflictingLocalRelations, "Different bounded candidate regions have conflicting local relations.")]).ToArray(),+ "conflicting local candidate evidence", witnesses);+ if (witness.LocalRelation == IntersectionLocalRelation.Crossing && Interior(curve, witness.ParameterOnA!.T!.Value, policy.ParameterTolerance)+ && Interior(patch, witness.ParameterOnB!.U!.Value, witness.ParameterOnB.V!.Value, policy.ParameterTolerance))+ return FromClosest(IntersectionRelation.Crossing, PredicateEvidenceKind.ToleranceBounded, closest, curve, patch, policy, closest.Diagnostics,+ "M3 near-zero candidate plus interior transverse tangent/normal evidence", witnesses);+ var diagnostics = closest.Diagnostics.Concat([new GeometryQueryDiagnostic(GeometryQueryDiagnosticCode.InsufficientSecondJetEvidence,+ "Near-zero distance and local tangency do not establish whole-domain touching.")]).ToArray();+ return FromClosest(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, closest, curve, patch, policy, diagnostics,+ "local contact candidate remains globally inconclusive", witnesses);+ }++ public static IntersectionResult Between(BoundedParametricPatch3 patch, BoundedParametricCurve3 curve) => Swap(Between(curve, patch));+ public static IntersectionResult Between(BoundedParametricPatch3 patch, BoundedParametricCurve3 curve, IntersectionPolicy policy) => Swap(Between(curve, patch, policy));++ public static IntersectionResult Between(BoundedParametricPatch3 a, BoundedParametricPatch3 b) => Between(a, b, IntersectionPolicy.Default);+ public static IntersectionResult Between(BoundedParametricPatch3 a, BoundedParametricPatch3 b, IntersectionPolicy policy)+ {+ ArgumentNullException.ThrowIfNull(a); ArgumentNullException.ThrowIfNull(b); policy.Validate();+ var closest = ClosestPointQuery.Between(a, b, policy.DistancePolicy);+ if (closest.Status == DistanceQueryStatus.Unknown) return FromUnknown(closest, a, b, policy);+ if (closest.Relation == DistanceRelation.Coincident && closest.Evidence == PredicateEvidenceKind.Structural && a.Domain == b.Domain)+ return FromClosest(IntersectionRelation.Coincident, PredicateEvidenceKind.Structural, closest, a, b, policy, [], "shared authored geometry identity", [PatchPatchWitness(a, b, closest, policy) ?? BasicWitness(closest, IntersectionLocalRelation.CoincidentCandidate)]);+ if (closest.Relation == DistanceRelation.Coincident && closest.Evidence == PredicateEvidenceKind.Structural)+ return FromClosest(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, closest, a, b, policy,+ [new(GeometryQueryDiagnosticCode.AmbiguousOverlap, "Shared support identity with different bounded domains does not establish whole-domain coincidence; partial overlap classification is deferred.")],+ "shared support identity has non-identical bounded domains");+ if (closest.Relation == DistanceRelation.Separated)+ return FromClosest(IntersectionRelation.Disjoint, closest.Evidence, closest, a, b, policy, [], "M3 distance gate proves bounded separation");+ var witness = PatchPatchWitness(a, b, closest, policy);+ var discovered = FindInteriorPatchPatchWitnesses(a, b, policy);+ if (witness is null || witness.LocalRelation != IntersectionLocalRelation.Crossing+ || !Interior(a, witness.ParameterOnA!.U!.Value, witness.ParameterOnA.V!.Value, policy.ParameterTolerance)+ || !Interior(b, witness.ParameterOnB!.U!.Value, witness.ParameterOnB.V!.Value, policy.ParameterTolerance))+ witness = discovered.FirstOrDefault() ?? witness;+ if (witness is null) return FromClosest(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, closest, a, b, policy, closest.Diagnostics, "near-zero distance lacks regular tangent planes");+ var witnesses = Merge(witness, discovered, policy.LinearTolerance);+ if (witnesses.Select(x => x.LocalRelation).Distinct().Count() > 1)+ return FromClosest(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, closest, a, b, policy,+ closest.Diagnostics.Concat([new GeometryQueryDiagnostic(GeometryQueryDiagnosticCode.ConflictingLocalRelations, "Different bounded candidate regions have conflicting local relations.")]).ToArray(),+ "conflicting local candidate evidence", witnesses);+ var pa = witness.ParameterOnA!; var pb = witness.ParameterOnB!;+ if (witness.LocalRelation == IntersectionLocalRelation.Crossing+ && Interior(a, pa.U!.Value, pa.V!.Value, policy.ParameterTolerance)+ && Interior(b, pb.U!.Value, pb.V!.Value, policy.ParameterTolerance))+ return FromClosest(IntersectionRelation.Crossing, PredicateEvidenceKind.ToleranceBounded, closest, a, b, policy, closest.Diagnostics,+ "M3 near-zero candidate plus interior transverse tangent planes", witnesses);+ var diagnostics = closest.Diagnostics.Concat([new GeometryQueryDiagnostic(GeometryQueryDiagnosticCode.AmbiguousOverlap,+ "Compatible tangent planes or boundary-only contact do not certify overlap or whole-domain touching.")]).ToArray();+ return FromClosest(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, closest, a, b, policy, diagnostics,+ "local patch contact remains globally inconclusive", witnesses);+ }++ private static IntersectionWitness? CurvePatchWitness(BoundedParametricCurve3 curve, BoundedParametricPatch3 patch, ClosestPointResult c, IntersectionPolicy p)+ {+ if (c.ParameterOnA?.T is not double t || c.ParameterOnB?.U is not double u || c.ParameterOnB.V is not double v || c.PointOnA is not Point3D a || c.PointOnB is not Point3D b) return null;+ try+ {+ var cj = curve.EvaluateJet1(t); var pj = patch.Evaluate(u, v); if (!cj.IsRegular || pj.Normal is null) return null;+ var dot = pj.Normal.Value.ToVector().Dot(cj.UnitTangent!.Value.ToVector());+ var local = double.Abs(dot) > double.Sin(p.AngularTolerance) ? IntersectionLocalRelation.Crossing : IntersectionLocalRelation.TouchingCandidate;+ var observation = new ContactObservation(dot, null, null, false, local == IntersectionLocalRelation.Crossing ? "transverse curve tangent and patch normal" : "curve tangent lies in patch tangent plane");+ return new(Mid(a, b), a, b, new(T: t), new(U: u, V: v), c.ComputedDistance ?? (a - b).Length, local, observation);+ }+ catch (Exception ex) when (ex is ArithmeticException or ArgumentOutOfRangeException) { return null; }+ }++ private static IntersectionWitness? PatchPatchWitness(BoundedParametricPatch3 a, BoundedParametricPatch3 b, ClosestPointResult c, IntersectionPolicy p)+ {+ if (c.ParameterOnA?.U is not double au || c.ParameterOnA.V is not double av || c.ParameterOnB?.U is not double bu || c.ParameterOnB.V is not double bv || c.PointOnA is not Point3D pa || c.PointOnB is not Point3D pb) return null;+ try+ {+ var ja = a.Evaluate(au, av); var jb = b.Evaluate(bu, bv); if (ja.Normal is null || jb.Normal is null) return null;+ var dot = ja.Normal.Value.ToVector().Dot(jb.Normal.Value.ToVector());+ var transverse = 1d - double.Abs(dot) > p.AngularTolerance;+ return new(Mid(pa, pb), pa, pb, new(U: au, V: av), new(U: bu, V: bv), c.ComputedDistance ?? (pa - pb).Length,+ transverse ? IntersectionLocalRelation.Crossing : IntersectionLocalRelation.TouchingCandidate,+ new(null, dot, null, false, transverse ? "transverse tangent planes" : "compatible tangent planes"));+ }+ catch (Exception ex) when (ex is ArithmeticException or ArgumentOutOfRangeException) { return null; }+ }++ private static IReadOnlyList<IntersectionWitness> FindInteriorCurvePatchWitnesses(BoundedParametricCurve3 curve, BoundedParametricPatch3 patch, IntersectionPolicy policy)+ {+ const int n = 5; var found = new List<IntersectionWitness>();+ for (var i = 1; i < n - 1; i++) for (var j = 1; j < n - 1; j++) for (var k = 1; k < n - 1; k++)+ {+ var t = curve.Domain.Map(i / (double)(n - 1)); var u = patch.Domain.U.Map(j / (double)(n - 1)); var v = patch.Domain.V.Map(k / (double)(n - 1));+ try+ {+ var a = curve.Evaluate(t); var b = patch.EvaluatePoint(u, v); var residual = (a - b).Length;+ if (residual > policy.LinearTolerance) continue;+ var cj = curve.EvaluateJet1(t); var pj = patch.Evaluate(u, v); if (!cj.IsRegular || pj.Normal is null) continue;+ var dot = pj.Normal.Value.ToVector().Dot(cj.UnitTangent!.Value.ToVector());+ var local = double.Abs(dot) > double.Sin(policy.AngularTolerance) ? IntersectionLocalRelation.Crossing : IntersectionLocalRelation.TouchingCandidate;+ found.Add(new(Mid(a, b), a, b, new(T: t), new(U: u, V: v), residual, local,+ new(dot, null, null, false, local == IntersectionLocalRelation.Crossing ? "interior transverse lattice witness" : "interior tangent lattice witness")));+ }+ catch (ArithmeticException) { }+ }+ return Deduplicate(found, policy.LinearTolerance);+ }++ private static IReadOnlyList<IntersectionWitness> FindInteriorPatchPatchWitnesses(BoundedParametricPatch3 a, BoundedParametricPatch3 b, IntersectionPolicy policy)+ {+ const int n = 5; var found = new List<IntersectionWitness>();+ for (var i = 1; i < n - 1; i++) for (var j = 1; j < n - 1; j++) for (var k = 1; k < n - 1; k++) for (var l = 1; l < n - 1; l++)+ {+ var au = a.Domain.U.Map(i / (double)(n - 1)); var av = a.Domain.V.Map(j / (double)(n - 1));+ var bu = b.Domain.U.Map(k / (double)(n - 1)); var bv = b.Domain.V.Map(l / (double)(n - 1));+ try+ {+ var pa = a.Evaluate(au, av); var pb = b.Evaluate(bu, bv); var residual = (pa.Point - pb.Point).Length;+ if (residual > policy.LinearTolerance || pa.Normal is null || pb.Normal is null) continue;+ var dot = pa.Normal.Value.ToVector().Dot(pb.Normal.Value.ToVector()); var transverse = 1d - double.Abs(dot) > policy.AngularTolerance;+ found.Add(new(Mid(pa.Point, pb.Point), pa.Point, pb.Point, new(U: au, V: av), new(U: bu, V: bv), residual,+ transverse ? IntersectionLocalRelation.Crossing : IntersectionLocalRelation.TouchingCandidate,+ new(null, dot, null, false, transverse ? "interior transverse lattice witness" : "interior compatible tangent-plane witness")));+ }+ catch (ArithmeticException) { }+ }+ return Deduplicate(found, policy.LinearTolerance);+ }++ private static List<CurvePlaneSample> SampleCurvePlane(BoundedParametricCurve3 curve, Plane3 plane, IntersectionPolicy policy, out List<GeometryQueryDiagnostic> diagnostics)+ {+ diagnostics = []; var n = int.Clamp(policy.SubdivisionBudget / 32, 9, 257); var result = new List<CurvePlaneSample>(n);+ for (var i = 0; i < n; i++)+ {+ var t = curve.Domain.Map(i / (double)(n - 1));+ try { var point = curve.Evaluate(t); var distance = plane.SignedDistance(point); if (double.IsFinite(distance)) result.Add(new(t, point, distance)); else diagnostics.Add(new(GeometryQueryDiagnosticCode.NonFiniteEvaluation, $"Non-finite signed distance at t={t:R}.")); }+ catch (ArithmeticException ex) { diagnostics.Add(new(GeometryQueryDiagnosticCode.NonFiniteEvaluation, ex.Message)); }+ }+ return result;+ }++ private static (CurvePlaneSample A, CurvePlaneSample B)? FirstBracket(IReadOnlyList<CurvePlaneSample> samples, double tolerance)+ {+ for (var i = 1; i < samples.Count; i++) if (samples[i - 1].Distance * samples[i].Distance < 0 && double.Abs(samples[i - 1].Distance) > tolerance && double.Abs(samples[i].Distance) > tolerance) return (samples[i - 1], samples[i]);+ return null;+ }++ private static CurvePlaneSample Bisect(BoundedParametricCurve3 curve, Plane3 plane, CurvePlaneSample a, CurvePlaneSample b, IntersectionPolicy policy)+ {+ for (var i = 0; i < policy.IterationBudget && b.T - a.T > policy.ParameterTolerance; i++)+ {+ var t = (a.T + b.T) / 2d; var point = curve.Evaluate(t); var candidate = new CurvePlaneSample(t, point, plane.SignedDistance(point));+ if (double.Abs(candidate.Distance) <= policy.LinearTolerance) return candidate;+ if (a.Distance * candidate.Distance <= 0) b = candidate; else a = candidate;+ }+ return double.Abs(a.Distance) <= double.Abs(b.Distance) ? a : b;+ }++ private static IReadOnlyList<CurvePlaneSample> AllRoots(BoundedParametricCurve3 curve, Plane3 plane, IReadOnlyList<CurvePlaneSample> samples, IntersectionPolicy policy)+ {+ var roots = new List<CurvePlaneSample>();+ for (var i = 1; i < samples.Count; i++)+ {+ var a = samples[i - 1]; var b = samples[i];+ if (a.Distance * b.Distance < 0) roots.Add(Bisect(curve, plane, a, b, policy));+ else if (double.Abs(a.Distance) <= policy.LinearTolerance) roots.Add(a);+ }+ if (double.Abs(samples[^1].Distance) <= policy.LinearTolerance) roots.Add(samples[^1]);+ return roots.OrderBy(x => x.T).Aggregate(new List<CurvePlaneSample>(), (list, item) =>+ { if (list.Count == 0 || double.Abs(item.T - list[^1].T) > policy.ParameterTolerance * 8) list.Add(item); return list; });+ }++ private static IReadOnlyList<IntersectionWitness> Merge(IntersectionWitness primary, IReadOnlyList<IntersectionWitness> discovered, double tolerance)+ => Deduplicate(new[] { primary }.Concat(discovered), tolerance);+ private static IReadOnlyList<IntersectionWitness> Deduplicate(IEnumerable<IntersectionWitness> source, double tolerance)+ {+ var result = new List<IntersectionWitness>();+ foreach (var witness in source.OrderBy(x => x.ParameterOnA?.T ?? x.ParameterOnA?.U ?? double.PositiveInfinity)+ .ThenBy(x => x.ParameterOnA?.V ?? double.PositiveInfinity).ThenBy(x => x.ParameterOnB?.U ?? double.PositiveInfinity).ThenBy(x => x.ParameterOnB?.V ?? double.PositiveInfinity))+ if (!result.Any(x => (x.Point - witness.Point).Length <= tolerance)) result.Add(witness);+ return result;+ }++ private static ContactObservation CurvePlaneObservation(BoundedParametricCurve3 curve, Plane3 plane, double t, IntersectionPolicy policy)+ {+ var jet = curve.EvaluateJet1(t); var first = jet.UnitTangent is null ? double.NaN : plane.Normal.ToVector().Dot(jet.UnitTangent.Value.ToVector()); double? second = null; var hasSecond = false;+ if (curve.SupportsSecondJet) { try { second = plane.Normal.ToVector().Dot(curve.EvaluateJet2(t).SecondDerivative); hasSecond = true; } catch (NotSupportedException) { } }+ return new(first, null, second, hasSecond, double.Abs(first) > policy.AngularTolerance ? "signed scalar crosses transversely" : hasSecond ? "stationary signed scalar with second-order observation" : "stationary signed scalar without second jet");+ }++ private static bool TryCurveScalarRange(BoundedParametricCurve3 curve, Plane3 plane, out Interval range)+ {+ if (curve.PointExpression is null) { range = default; return false; }+ var scalar = Scalar(curve.PointExpression.X, curve.PointExpression.Y, curve.PointExpression.Z, plane);+ return IntervalEvaluator.TryEvaluate(scalar, new(new(curve.Domain.Minimum, curve.Domain.Maximum), new(-1, 1)), out range);+ }++ private static bool TryPatchScalarRange(BoundedParametricPatch3 patch, Plane3 plane, out Interval range)+ {+ if (patch.PointExpression is null) { range = default; return false; }+ var p = patch.PointExpression; return IntervalEvaluator.TryEvaluate(Scalar(p.X, p.Y, p.Z, plane), patch.Domain, out range);+ }++ private static SurfaceScalarExpression Scalar(SurfaceScalarExpression x, SurfaceScalarExpression y, SurfaceScalarExpression z, Plane3 plane)+ {+ var n = plane.Normal.ToVector();+ return SurfaceExpression.Subtract(SurfaceExpression.Add(SurfaceExpression.Add(Scale(x, n.X), Scale(y, n.Y)), Scale(z, n.Z)), SurfaceExpression.Length(n.Dot(plane.Origin - Point3D.Origin)));+ }+ private static SurfaceScalarExpression Scale(SurfaceScalarExpression x, double factor) => SurfaceExpression.Multiply(x, SurfaceExpression.Number(factor));++ private static IEnumerable<PatchPlaneSample> PatchPlaneCandidates(BoundedParametricPatch3 patch, Plane3 plane, IntersectionPolicy policy)+ {+ var n = Samples(policy.SubdivisionBudget); var list = new List<PatchPlaneSample>();+ for (var i = 0; i < n; i++) for (var j = 0; j < n; j++)+ {+ var u = patch.Domain.U.Map(i / (double)(n - 1)); var v = patch.Domain.V.Map(j / (double)(n - 1));+ try { var point = patch.EvaluatePoint(u, v); var d = plane.SignedDistance(point); if (double.Abs(d) <= policy.LinearTolerance) list.Add(new(u, v, point, d)); } catch (ArithmeticException) { }+ }+ return list.OrderBy(x => double.Abs(x.Distance)).ThenBy(x => x.U).ThenBy(x => x.V);+ }++ private static ContactObservation PatchPlaneObservation(BoundedParametricPatch3 patch, Plane3 plane, double u, double v, IntersectionPolicy policy)+ {+ var jet = patch.Evaluate(u, v); var dot = jet.Normal?.ToVector().Dot(plane.Normal.ToVector());+ return new(null, dot, null, patch.SupportsSecondJet, dot is double d && 1d - double.Abs(d) <= policy.AngularTolerance ? "compatible tangent planes" : "transverse or singular tangent plane");+ }++ private static IntersectionWitness Witness(BoundedParametricCurve3 curve, Plane3 plane, CurvePlaneSample s, IntersectionLocalRelation local, ContactObservation? contact)+ => new(s.Point, s.Point, s.Point, new(T: s.T), null, double.Abs(s.Distance), local, contact);+ private static IntersectionWitness Witness(BoundedParametricPatch3 patch, Plane3 plane, SignedSideWitness s, IntersectionLocalRelation local, ContactObservation? contact)+ => new(s.Point, s.Point, s.Point, new(U: s.U, V: s.V), null, double.Abs(s.SignedDistance), local, contact);+ private static IntersectionWitness Witness(BoundedParametricPatch3 patch, Plane3 plane, PatchPlaneSample s, IntersectionLocalRelation local, ContactObservation? contact)+ => new(s.Point, s.Point, s.Point, new(U: s.U, V: s.V), null, double.Abs(s.Distance), local, contact);++ private static IntersectionResult FromUnknown(ClosestPointResult c, object a, object b, IntersectionPolicy p)+ => Result(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, p, [], a, b, Stats(c), c.Diagnostics, "M3 distance query exhausted its bounded evidence budget");+ private static IntersectionResult FromClosest(IntersectionRelation relation, PredicateEvidenceKind evidence, ClosestPointResult c, object a, object b, IntersectionPolicy p, IReadOnlyList<GeometryQueryDiagnostic> diagnostics, string provenance, IReadOnlyList<IntersectionWitness>? witnesses = null)+ => Result(relation, evidence, p, witnesses ?? [], a, b, Stats(c), diagnostics, provenance);+ private static IntersectionStatistics Stats(ClosestPointResult c) => new(0, c.Statistics.Subdivisions, c.Statistics.Iterations, 1, c.Statistics.CandidateCount, c.Statistics.BudgetExhausted);+ private static IntersectionWitness BasicWitness(ClosestPointResult c, IntersectionLocalRelation relation)+ {+ var a = c.PointOnA ?? Point3D.Origin; var b = c.PointOnB ?? a;+ return new(Mid(a, b), a, b, Parameters(c.ParameterOnA), Parameters(c.ParameterOnB), c.ComputedDistance ?? (a - b).Length, relation, null);+ }+ private static IntersectionParameters? Parameters(DistanceParameters? p) => p is null ? null : new(p.T, p.U, p.V);++ private static IntersectionResult Unknown(object a, object b, IntersectionPolicy p, IReadOnlyList<GeometryQueryDiagnostic> diagnostics)+ => Result(IntersectionRelation.Unknown, PredicateEvidenceKind.Unknown, p, [], a, b, new(0, 0, 0, 0, 0, false), diagnostics, "invalid or unavailable bounded evidence");+ private static IntersectionResult Result(IntersectionRelation relation, PredicateEvidenceKind evidence, IntersectionPolicy policy, IReadOnlyList<IntersectionWitness> witnesses,+ object a, object b, IntersectionStatistics statistics, IReadOnlyList<GeometryQueryDiagnostic> diagnostics, string provenance)+ => new(relation, evidence, policy, witnesses, witnesses.Select(x => x.Residual).ToArray(), Domain(a), Domain(b), statistics, Operand(a), Operand(b), provenance, diagnostics);+ private static IntersectionResult Swap(IntersectionResult r) => r with+ {+ DomainA = r.DomainB, DomainB = r.DomainA, OperandA = r.OperandB, OperandB = r.OperandA,+ WitnessPoints = r.WitnessPoints.Select(w => w with { PointOnA = w.PointOnB, PointOnB = w.PointOnA, ParameterOnA = w.ParameterOnB, ParameterOnB = w.ParameterOnA }).ToArray()+ };++ private static IntersectionDomain Domain(object x) => x switch+ {+ BoundedParametricCurve3 c => new("Curve", c.Domain.Minimum, c.Domain.Maximum),+ BoundedParametricPatch3 p => new("Patch", p.Domain.U.Minimum, p.Domain.U.Maximum, p.Domain.V.Minimum, p.Domain.V.Maximum),+ Plane3 => new("UnboundedPlane", null, null),+ _ => new("Unknown", null, null)+ };+ private static IntersectionOperand Operand(object x) => x switch+ {+ BoundedParametricCurve3 c => new("Curve", c.Identity, c.Provenance),+ BoundedParametricPatch3 p => new("Patch", p.Identity, p.GeometryProvenance),+ Plane3 => new("Plane", null, new("query-plane")),+ _ => new("Unknown", null, null)+ };++ private static bool Interior(BoundedParametricCurve3 c, double t, double tolerance) => t > c.Domain.Minimum + tolerance && t < c.Domain.Maximum - tolerance;+ private static bool Interior(BoundedParametricPatch3 p, double u, double v, double tolerance) => u > p.Domain.U.Minimum + tolerance && u < p.Domain.U.Maximum - tolerance && v > p.Domain.V.Minimum + tolerance && v < p.Domain.V.Maximum - tolerance;+ private static bool Valid(Plane3 p) { var n = p.Normal.ToVector(); return double.IsFinite(n.X) && double.IsFinite(n.Y) && double.IsFinite(n.Z) && n.LengthSquared > .5d; }+ private static bool SameStrictSign(double a, double b, double tolerance) => (a > tolerance && b > tolerance) || (a < -tolerance && b < -tolerance);+ private static int Samples(int budget) => int.Clamp((int)double.Sqrt(budget), 3, 33);+ private static int MaxDepth(int budget) => int.Clamp((int)double.Log2(double.Max(1, budget)) / 2, 0, 12);+ private static Point3D Mid(Point3D a, Point3D b) => new((a.X + b.X) / 2d, (a.Y + b.Y) / 2d, (a.Z + b.Z) / 2d);+ private readonly record struct CurvePlaneSample(double T, Point3D Point, double Distance);+ private sealed record PatchPlaneSample(double U, double V, Point3D Point, double Distance);+}diff --git a/Aetheris.Geometry/SignedSideQuery.cs b/Aetheris.Geometry/SignedSideQuery.csindex d0dff3a9..928dc03f 100644--- a/Aetheris.Geometry/SignedSideQuery.cs+++ b/Aetheris.Geometry/SignedSideQuery.cs@@ -21,7 +21,10 @@ public enum GeometryQueryDiagnosticCodeEvidenceUnavailable,IterationBudgetExhausted,UnsupportedPairFamily,- IllConditionedCandidate+ IllConditionedCandidate,+ AmbiguousOverlap,+ InsufficientSecondJetEvidence,+ ConflictingLocalRelations}public sealed record GeometryQueryDiagnostic(GeometryQueryDiagnosticCode Code, string Message);diff --git a/Aetheris.slnx b/Aetheris.slnxindex 5342d829..c95def5b 100644--- a/Aetheris.slnx+++ b/Aetheris.slnx@@ -29,6 +29,7 @@<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.Geometry.M4Evidence/Aetheris.Geometry.M4Evidence.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-m4/api-architecture.json b/docs/geometry/artifacts/reasoning-m4/api-architecture.jsonnew file mode 100644index 00000000..27409ce5--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/api-architecture.json@@ -0,0 +1,61 @@+{+ "owner": "Aetheris.Geometry",+ "matrix": [+ "Curve-Plane",+ "Patch-Plane",+ "Curve-Patch",+ "Patch-Patch"+ ],+ "relationStates": [+ "Disjoint",+ "Crossing",+ "Touching",+ "Coincident",+ "Overlapping",+ "Unknown"+ ],+ "evidenceClasses": [+ "Structural",+ "Certified",+ "ToleranceBounded",+ "Sampled",+ "Heuristic",+ "Unknown"+ ],+ "policy": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "resultFields": [+ "Relation",+ "Evidence",+ "ToleranceUsed",+ "WitnessPoints",+ "Residuals",+ "DomainA",+ "DomainB",+ "Statistics",+ "OperandA",+ "OperandB",+ "Provenance",+ "Diagnostics",+ "IsDefinitelyDisjoint",+ "WitnessesAreAuthoritativeTrims"+ ],+ "witnessFields": [+ "Point",+ "PointOnA",+ "PointOnB",+ "ParameterOnA",+ "ParameterOnB",+ "Residual",+ "LocalRelation",+ "Contact"+ ],+ "witnessAuthority": "EvidenceOnly; NonAuthoritative; NonExportableAsTrim",+ "futureSeam": "ContactClassification / ContactOrder (not implemented)"+}diff --git a/docs/geometry/artifacts/reasoning-m4/bounded-constructive-regression.json b/docs/geometry/artifacts/reasoning-m4/bounded-constructive-regression.jsonnew file mode 100644index 00000000..59ffcdcd--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/bounded-constructive-regression.json@@ -0,0 +1,6 @@+{+ "success": true,+ "resultFamily": "Hyperbola3Curve",+ "unchangedRoute": "TransverseConePlaneIntersection.IntersectWorldZ",+ "genericQueryReplacement": false+}diff --git a/docs/geometry/artifacts/reasoning-m4/curve-patch-fixtures.json b/docs/geometry/artifacts/reasoning-m4/curve-patch-fixtures.jsonnew file mode 100644index 00000000..cda828a3--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/curve-patch-fixtures.json@@ -0,0 +1,338 @@+{+ "separated": {+ "Relation": "Disjoint",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": 0,+ "MaximumA": 2,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 5642,+ "Iterations": 59,+ "ClosestPointCalls": 1,+ "CandidateRegions": 6008,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "disjoint-line"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "M3 distance gate proves bounded separation",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": true,+ "WitnessesAreAuthoritativeTrims": false+ },+ "transverse": {+ "Relation": "Crossing",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 1,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "Crossing",+ "Contact": {+ "TangentNormalDot": 1,+ "NormalNormalDot": null,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "transverse curve tangent and patch normal"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": 0,+ "MaximumA": 2,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 5642,+ "Iterations": 59,+ "ClosestPointCalls": 1,+ "CandidateRegions": 6008,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "crossing-line"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "M3 near-zero candidate plus interior transverse tangent/normal evidence",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "nearContact": {+ "Relation": "Unknown",+ "Evidence": "Unknown",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 0.5,+ "U": null,+ "V": null+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": 0,+ "NormalNormalDot": null,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior tangent lattice witness"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": 0,+ "MaximumA": 1,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 5642,+ "Iterations": 59,+ "ClosestPointCalls": 1,+ "CandidateRegions": 6008,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "in-plane"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "local contact candidate remains globally inconclusive",+ "Diagnostics": [+ {+ "Code": "InsufficientSecondJetEvidence",+ "Message": "Near-zero distance and local tangency do not establish whole-domain touching."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "budgetLimited": {+ "Relation": "Unknown",+ "Evidence": "Unknown",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 16,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": 0,+ "MaximumA": 2,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 0,+ "Iterations": 0,+ "ClosestPointCalls": 1,+ "CandidateRegions": 0,+ "BudgetExhausted": true+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "crossing-line"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "M3 distance query exhausted its bounded evidence budget",+ "Diagnostics": [+ {+ "Code": "SubdivisionBudgetExhausted",+ "Message": "The minimum deterministic 3D lattice requires 35 candidates; policy permits 16."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ }+}diff --git a/docs/geometry/artifacts/reasoning-m4/curve-plane-fixtures.json b/docs/geometry/artifacts/reasoning-m4/curve-plane-fixtures.jsonnew file mode 100644index 00000000..4ddd64a6--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/curve-plane-fixtures.json@@ -0,0 +1,441 @@+{+ "disjoint": {+ "Relation": "Disjoint",+ "Evidence": "Certified",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": 0,+ "MaximumA": 2,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 257,+ "Subdivisions": 0,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 0,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "disjoint-line"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "affine signed scalar has strict bounded endpoint separation",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": true,+ "WitnessesAreAuthoritativeTrims": false+ },+ "crossing": {+ "Relation": "Crossing",+ "Evidence": "Certified",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 1,+ "U": null,+ "V": null+ },+ "ParameterOnB": null,+ "Residual": 0,+ "LocalRelation": "Crossing",+ "Contact": {+ "TangentNormalDot": 1,+ "NormalNormalDot": null,+ "SignedSecondDerivative": 0,+ "HasSecondJet": true,+ "Summary": "signed scalar crosses transversely"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": 0,+ "MaximumA": 2,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 257,+ "Subdivisions": 0,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "crossing-line"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "continuous signed scalar has opposite strict-side witnesses",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "tangent": {+ "Relation": "Touching",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ParameterOnB": null,+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": 0,+ "NormalNormalDot": null,+ "SignedSecondDerivative": 2,+ "HasSecondJet": true,+ "Summary": "stationary signed scalar with second-order observation"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 257,+ "Subdivisions": 1,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "tangent-parabola"+ },+ "Provenance": {+ "Source": "M4 scientific fixture",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "whole-domain one-sided interval plus isolated second-order tangent contact",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "structuralZero": {+ "Relation": "Coincident",+ "Evidence": "Structural",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -1,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": -1,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": -1,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ParameterOnB": null,+ "Residual": 0,+ "LocalRelation": "CoincidentCandidate",+ "Contact": null+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": 0,+ "MaximumA": 2,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 257,+ "Subdivisions": 0,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "structural-zero"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "analytic-line/plane structural zero over bounded segment",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "unknown": {+ "Relation": "Unknown",+ "Evidence": "Unknown",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": 0,+ "U": null,+ "V": null+ },+ "ParameterOnB": null,+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": 0,+ "NormalNormalDot": null,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "stationary signed scalar without second jet"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Curve",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": null,+ "MaximumB": null+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 257,+ "Subdivisions": 1,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Curve",+ "Identity": {+ "StableId": "first-jet-only"+ },+ "Provenance": {+ "Source": "M4 fixture",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "local curve/plane contact remains globally inconclusive",+ "Diagnostics": [+ {+ "Code": "InsufficientSecondJetEvidence",+ "Message": "A local contact candidate does not establish a whole-domain touching relation."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ }+}diff --git a/docs/geometry/artifacts/reasoning-m4/deterministic-hashes.json b/docs/geometry/artifacts/reasoning-m4/deterministic-hashes.jsonnew file mode 100644index 00000000..7f9738cc--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/deterministic-hashes.json@@ -0,0 +1,25 @@+{+ "algorithm": "SHA-256",+ "reports": [+ {+ "name": "curve-patch",+ "stable": true,+ "sha256": "64daee483b9dbe968966397db2088d9eb25b9975bc1086a4c8f0b47afcdc3a52"+ },+ {+ "name": "curve-plane",+ "stable": true,+ "sha256": "7d3722b1b83363f6073e4a5b5d0f606b00c0fae22ee844b994e04f6992c6d97c"+ },+ {+ "name": "patch-patch",+ "stable": true,+ "sha256": "d381e8479b511be51f592fd49565e899f99bbed507173dc477d6df05cefb35ff"+ },+ {+ "name": "patch-plane",+ "stable": true,+ "sha256": "73459552ce46d0cecda868c9f77d9a94b09b446d5ab394c55d0fbbe457eb565f"+ }+ ]+}diff --git a/docs/geometry/artifacts/reasoning-m4/intersection-audit.md b/docs/geometry/artifacts/reasoning-m4/intersection-audit.mdnew file mode 100644index 00000000..df11d1e7--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/intersection-audit.md@@ -0,0 +1,20 @@+# M4 intersection authority audit++The audit covered Kernel.Core, BRep Boolean routes, analytic cone/plane support, CLI line/surface sectioning, clipping and triangulation, Panel boundary and mate checks, Drawing HLR, SurfaceMeshIR, STEP import/recovery, and restricted-field trim prototypes.++| Area | Classification | Authority assessment | M4 action |+|---|---|---|---|+| `TransverseConePlaneIntersection` | bounded constructive, analytic | healthy bounded construction: caller intent fixes cone/world-Z section and hyperbola family | unchanged; regression tested |+| `BrepBoolean` and recognized family builders | topology-authoring, bounded recognized cases | contained legacy behavior; topology is explicitly requested by a Boolean and routed through recognized families/JudgmentEngine | unchanged; generic query has no dependency on it |+| STEP analyzer plane sections and ray hits | internal query-like; analytic plus tessellated fallback | contained analysis behavior; section output is explicitly requested and provenance identifies fallback | unchanged |+| STEP importer polygon crossings/recovery | internal topology recovery, approximate planar predicates | future architectural risk because imported loop-role recovery can affect topology; already bounded by tolerance, diagnostics, and JudgmentEngine | documented, not refactored in M4 |+| Firmament restricted-field/marching contours | approximate/sampled, internal-only | contained legacy prototype; records say numerical-only/not exportable and BRep topology not emitted | unchanged |+| Profile arrangement line/arc intersections | topology-authoring inside explicit profile construction | healthy bounded construction: authored profile intent requires splitting/reconstruction | unchanged |+| Planar triangulation, display-loop checks, feature-band clipping | internal-only planar predicates | healthy implementation detail for already-authored topology/display | unchanged |+| Drawing projection/HLR segment cuts | approximate display-only | no model authority | unchanged |+| SurfaceMeshIR and display tessellation | sampled/approximate visualization | no topology authoring; analytic BRep remains owner | unchanged |+| Panel boundary self-crossing and G0/G1/G2 mates | sampled validation evidence | healthy query-like validation; does not create topology | unchanged; Panel patches dogfood M4 |+| BRep interference and AABB overlap | generic query-like, bounded | observational verification/candidate pruning | unchanged |++No release-blocking path was found where an arbitrary M4 numerical witness directly becomes an edge, trim, face, or Boolean result. The principal future risk is STEP recovery, where approximate planar crossing facts participate in import normalization; that path is explicit, diagnosed, and utility-selected, so a broad M4 refactor would increase risk without strengthening the new public predicate.+diff --git a/docs/geometry/artifacts/reasoning-m4/panel-cad-dogfood.json b/docs/geometry/artifacts/reasoning-m4/panel-cad-dogfood.jsonnew file mode 100644index 00000000..de24e69e--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/panel-cad-dogfood.json@@ -0,0 +1,340 @@+{+ "panelPlane": {+ "Relation": "Disjoint",+ "Evidence": "Certified",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 1,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "panel"+ },+ "Provenance": {+ "Source": "cad:M4-panel",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide whole-domain strict-side result",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": true,+ "WitnessesAreAuthoritativeTrims": false+ },+ "panelPanelGap": {+ "Relation": "Disjoint",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 7186,+ "Iterations": 61,+ "ClosestPointCalls": 1,+ "CandidateRegions": 7690,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "panel"+ },+ "Provenance": {+ "Source": "cad:M4-panel",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "panel-gap"+ },+ "Provenance": {+ "Source": "cad:M4-panel-gap",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "M3 distance gate proves bounded separation",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": true,+ "WitnessesAreAuthoritativeTrims": false+ },+ "panelPlaneCrossing": {+ "Relation": "Crossing",+ "Evidence": "Certified",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -0.75,+ "Y": -0.75,+ "Z": -0.75+ },+ "PointOnA": {+ "X": -0.75,+ "Y": -0.75,+ "Z": -0.75+ },+ "PointOnB": {+ "X": -0.75,+ "Y": -0.75,+ "Z": -0.75+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.75,+ "V": -0.75+ },+ "ParameterOnB": null,+ "Residual": 0.75,+ "LocalRelation": "Crossing",+ "Contact": null+ },+ {+ "Point": {+ "X": 0.75,+ "Y": -0.75,+ "Z": 0.75+ },+ "PointOnA": {+ "X": 0.75,+ "Y": -0.75,+ "Z": 0.75+ },+ "PointOnB": {+ "X": 0.75,+ "Y": -0.75,+ "Z": 0.75+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.75,+ "V": -0.75+ },+ "ParameterOnB": null,+ "Residual": 0.75,+ "LocalRelation": "Crossing",+ "Contact": null+ }+ ],+ "Residuals": [+ 0.75,+ 0.75+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 3,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 2,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "panel-crossing"+ },+ "Provenance": {+ "Source": "cad:M4-panel-crossing",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide opposite-side bounded witnesses establish crossing",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "panelPlaneTangent": {+ "Relation": "Touching",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "ParameterOnB": null,+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": true,+ "Summary": "compatible tangent planes"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 64,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": true+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "panel-tangent"+ },+ "Provenance": {+ "Source": "cad:M4-panel-tangent",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide-backed whole-domain one-sided interval plus tangent-plane contact",+ "Diagnostics": [+ {+ "Code": "SubdivisionBudgetExhausted",+ "Message": "Certification remained inconclusive at depth 6 with leaf budget 10000."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ }+}diff --git a/docs/geometry/artifacts/reasoning-m4/patch-patch-fixtures.json b/docs/geometry/artifacts/reasoning-m4/patch-patch-fixtures.jsonnew file mode 100644index 00000000..87e30951--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/patch-patch-fixtures.json@@ -0,0 +1,1211 @@+{+ "separated": {+ "Relation": "Disjoint",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 7186,+ "Iterations": 61,+ "ClosestPointCalls": 1,+ "CandidateRegions": 7690,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "parallel-gap"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "M3 distance gate proves bounded separation",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": true,+ "WitnessesAreAuthoritativeTrims": false+ },+ "transverse": {+ "Relation": "Crossing",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": -0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": -0.5,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.5,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": -0.5,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "Crossing",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 0,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior transverse lattice witness"+ }+ },+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "Crossing",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 0,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior transverse lattice witness"+ }+ },+ {+ "Point": {+ "X": 0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0.5,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.5,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": 0.5,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "Crossing",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 0,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior transverse lattice witness"+ }+ }+ ],+ "Residuals": [+ 0,+ 0,+ 0+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 7186,+ "Iterations": 61,+ "ClosestPointCalls": 1,+ "CandidateRegions": 7690,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "vertical"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "M3 near-zero candidate plus interior transverse tangent planes",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "tangentCompatible": {+ "Relation": "Unknown",+ "Evidence": "Unknown",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -0.5,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnA": {+ "X": -0.5,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": -0.5,+ "Y": -0.5,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.5,+ "V": -0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": -0.5,+ "V": -0.5+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": -0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": -0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": -0.5,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.5,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": -0.5,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": -0.5,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnA": {+ "X": -0.5,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": -0.5,+ "Y": 0.5,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.5,+ "V": 0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": -0.5,+ "V": 0.5+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": -0.5,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": -0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": -0.5+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0.5,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": 0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": 0.5+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0.5,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnA": {+ "X": 0.5,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0.5,+ "Y": -0.5,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.5,+ "V": -0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0.5,+ "V": -0.5+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0.5,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.5,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": 0.5,+ "V": 0+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0.5,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnA": {+ "X": 0.5,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0.5,+ "Y": 0.5,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.5,+ "V": 0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0.5,+ "V": 0.5+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ }+ ],+ "Residuals": [+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0,+ 0+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 7186,+ "Iterations": 61,+ "ClosestPointCalls": 1,+ "CandidateRegions": 7690,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "compatible"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "local patch contact remains globally inconclusive",+ "Diagnostics": [+ {+ "Code": "AmbiguousOverlap",+ "Message": "Compatible tangent planes or boundary-only contact do not certify overlap or whole-domain touching."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "structurallyCoincident": {+ "Relation": "Coincident",+ "Evidence": "Structural",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -1,+ "Y": -1,+ "Z": 0+ },+ "PointOnA": {+ "X": -1,+ "Y": -1,+ "Z": 0+ },+ "PointOnB": {+ "X": -1,+ "Y": -1,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": -1,+ "V": -1+ },+ "ParameterOnB": {+ "T": null,+ "U": -1,+ "V": -1+ },+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "compatible tangent planes"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 0,+ "Iterations": 0,+ "ClosestPointCalls": 1,+ "CandidateRegions": 0,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "shared authored geometry identity",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "numericalNearZero": {+ "Relation": "Unknown",+ "Evidence": "Unknown",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -0.5,+ "Y": -0.5,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": -0.5,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": -0.5,+ "Y": -0.5,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.5,+ "V": -0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": -0.5,+ "V": -0.5+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": -0.5,+ "Y": 0,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": -0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": -0.5,+ "Y": 0,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.5,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": -0.5,+ "V": 0+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": -0.5,+ "Y": 0.5,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": -0.5,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": -0.5,+ "Y": 0.5,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.5,+ "V": 0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": -0.5,+ "V": 0.5+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0,+ "Y": -0.5,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": 0,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": -0.5,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": -0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": -0.5+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0,+ "Y": 0.5,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": 0,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0.5,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": 0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0,+ "V": 0.5+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0.5,+ "Y": -0.5,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": 0.5,+ "Y": -0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0.5,+ "Y": -0.5,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.5,+ "V": -0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0.5,+ "V": -0.5+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0.5,+ "Y": 0,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": 0.5,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0.5,+ "Y": 0,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.5,+ "V": 0+ },+ "ParameterOnB": {+ "T": null,+ "U": 0.5,+ "V": 0+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ },+ {+ "Point": {+ "X": 0.5,+ "Y": 0.5,+ "Z": 2.5E-07+ },+ "PointOnA": {+ "X": 0.5,+ "Y": 0.5,+ "Z": 0+ },+ "PointOnB": {+ "X": 0.5,+ "Y": 0.5,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.5,+ "V": 0.5+ },+ "ParameterOnB": {+ "T": null,+ "U": 0.5,+ "V": 0.5+ },+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": false,+ "Summary": "interior compatible tangent-plane witness"+ }+ }+ ],+ "Residuals": [+ 5E-07,+ 5E-07,+ 5E-07,+ 5E-07,+ 5E-07,+ 5E-07,+ 5E-07,+ 5E-07,+ 5E-07+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 7186,+ "Iterations": 61,+ "ClosestPointCalls": 1,+ "CandidateRegions": 7690,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "near"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "local patch contact remains globally inconclusive",+ "Diagnostics": [+ {+ "Code": "AmbiguousOverlap",+ "Message": "Compatible tangent planes or boundary-only contact do not certify overlap or whole-domain touching."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "budgetLimited": {+ "Relation": "Unknown",+ "Evidence": "Unknown",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 16,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 0,+ "Iterations": 0,+ "ClosestPointCalls": 1,+ "CandidateRegions": 0,+ "BudgetExhausted": true+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "horizontal"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "vertical"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "M3 distance query exhausted its bounded evidence budget",+ "Diagnostics": [+ {+ "Code": "SubdivisionBudgetExhausted",+ "Message": "The minimum deterministic 4D lattice requires 97 candidates; policy permits 16."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ }+}diff --git a/docs/geometry/artifacts/reasoning-m4/patch-plane-fixtures.json b/docs/geometry/artifacts/reasoning-m4/patch-plane-fixtures.jsonnew file mode 100644index 00000000..e8d78652--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/patch-plane-fixtures.json@@ -0,0 +1,440 @@+{+ "disjoint": {+ "Relation": "Disjoint",+ "Evidence": "Certified",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 1,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "patch-above"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide whole-domain strict-side result",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": true,+ "WitnessesAreAuthoritativeTrims": false+ },+ "crossing": {+ "Relation": "Crossing",+ "Evidence": "Certified",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -0.75,+ "Y": -0.75,+ "Z": -0.75+ },+ "PointOnA": {+ "X": -0.75,+ "Y": -0.75,+ "Z": -0.75+ },+ "PointOnB": {+ "X": -0.75,+ "Y": -0.75,+ "Z": -0.75+ },+ "ParameterOnA": {+ "T": null,+ "U": -0.75,+ "V": -0.75+ },+ "ParameterOnB": null,+ "Residual": 0.75,+ "LocalRelation": "Crossing",+ "Contact": null+ },+ {+ "Point": {+ "X": 0.75,+ "Y": -0.75,+ "Z": 0.75+ },+ "PointOnA": {+ "X": 0.75,+ "Y": -0.75,+ "Z": 0.75+ },+ "PointOnB": {+ "X": 0.75,+ "Y": -0.75,+ "Z": 0.75+ },+ "ParameterOnA": {+ "T": null,+ "U": 0.75,+ "V": -0.75+ },+ "ParameterOnB": null,+ "Residual": 0.75,+ "LocalRelation": "Crossing",+ "Contact": null+ }+ ],+ "Residuals": [+ 0.75,+ 0.75+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 3,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 2,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "crossing-saddle"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide opposite-side bounded witnesses establish crossing",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "tangent": {+ "Relation": "Touching",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnA": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "PointOnB": {+ "X": 0,+ "Y": 0,+ "Z": 0+ },+ "ParameterOnA": {+ "T": null,+ "U": 0,+ "V": 0+ },+ "ParameterOnB": null,+ "Residual": 0,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": true,+ "Summary": "compatible tangent planes"+ }+ }+ ],+ "Residuals": [+ 0+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 64,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": true+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "tangent-paraboloid"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide-backed whole-domain one-sided interval plus tangent-plane contact",+ "Diagnostics": [+ {+ "Code": "SubdivisionBudgetExhausted",+ "Message": "Certification remained inconclusive at depth 6 with leaf budget 10000."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "toleranceSensitivity": {+ "loose": {+ "Relation": "Touching",+ "Evidence": "ToleranceBounded",+ "ToleranceUsed": {+ "LinearTolerance": 1E-06,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [+ {+ "Point": {+ "X": -1,+ "Y": -1,+ "Z": 5E-07+ },+ "PointOnA": {+ "X": -1,+ "Y": -1,+ "Z": 5E-07+ },+ "PointOnB": {+ "X": -1,+ "Y": -1,+ "Z": 5E-07+ },+ "ParameterOnA": {+ "T": null,+ "U": -1,+ "V": -1+ },+ "ParameterOnB": null,+ "Residual": 5E-07,+ "LocalRelation": "TouchingCandidate",+ "Contact": {+ "TangentNormalDot": null,+ "NormalNormalDot": 1,+ "SignedSecondDerivative": null,+ "HasSecondJet": true,+ "Summary": "compatible tangent planes"+ }+ }+ ],+ "Residuals": [+ 5E-07+ ],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 4096,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": true+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "near-plane-loose"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide-backed whole-domain one-sided interval plus tangent-plane contact",+ "Diagnostics": [+ {+ "Code": "SubdivisionBudgetExhausted",+ "Message": "Certification remained inconclusive at depth 6 with leaf budget 10000."+ }+ ],+ "IsDefinitelyDisjoint": false,+ "WitnessesAreAuthoritativeTrims": false+ },+ "tight": {+ "Relation": "Disjoint",+ "Evidence": "Certified",+ "ToleranceUsed": {+ "LinearTolerance": 1E-08,+ "AngularTolerance": 1E-09,+ "ParameterTolerance": 1E-10,+ "IterationBudget": 96,+ "SubdivisionBudget": 10000,+ "EvidencePreference": "PreferCertified"+ },+ "WitnessPoints": [],+ "Residuals": [],+ "DomainA": {+ "Kind": "Patch",+ "MinimumA": -1,+ "MaximumA": 1,+ "MinimumB": -1,+ "MaximumB": 1+ },+ "DomainB": {+ "Kind": "UnboundedPlane",+ "MinimumA": null,+ "MaximumA": null,+ "MinimumB": null,+ "MaximumB": null+ },+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 1,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ },+ "OperandA": {+ "Kind": "Patch",+ "Identity": {+ "StableId": "near-plane-tight"+ },+ "Provenance": {+ "Source": "M4 evidence",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "OperandB": {+ "Kind": "Plane",+ "Identity": null,+ "Provenance": {+ "Source": "query-plane",+ "SemanticOwner": null,+ "IsGenerated": false+ }+ },+ "Provenance": "SignedSide whole-domain strict-side result",+ "Diagnostics": [],+ "IsDefinitelyDisjoint": true,+ "WitnessesAreAuthoritativeTrims": false+ }+ }+}diff --git a/docs/geometry/artifacts/reasoning-m4/performance.json b/docs/geometry/artifacts/reasoning-m4/performance.jsonnew file mode 100644index 00000000..3dd31ee2--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/performance.json@@ -0,0 +1,61 @@+{+ "note": "Calibration only; no optimization campaign.",+ "operations": [+ {+ "Name": "curve-plane",+ "iterations": 25,+ "elapsedMilliseconds": 3.5612,+ "nanosecondsPerQuery": 142448,+ "Statistics": {+ "Samples": 257,+ "Subdivisions": 0,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 1,+ "BudgetExhausted": false+ }+ },+ {+ "Name": "patch-plane",+ "iterations": 25,+ "elapsedMilliseconds": 0.4765,+ "nanosecondsPerQuery": 19060,+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 3,+ "Iterations": 0,+ "ClosestPointCalls": 0,+ "CandidateRegions": 2,+ "BudgetExhausted": false+ }+ },+ {+ "Name": "curve-patch",+ "iterations": 25,+ "elapsedMilliseconds": 117.0149,+ "nanosecondsPerQuery": 4680596,+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 5642,+ "Iterations": 59,+ "ClosestPointCalls": 1,+ "CandidateRegions": 6008,+ "BudgetExhausted": false+ }+ },+ {+ "Name": "patch-patch",+ "iterations": 25,+ "elapsedMilliseconds": 107.7707,+ "nanosecondsPerQuery": 4310828,+ "Statistics": {+ "Samples": 0,+ "Subdivisions": 7186,+ "Iterations": 61,+ "ClosestPointCalls": 1,+ "CandidateRegions": 7690,+ "BudgetExhausted": false+ }+ }+ ]+}diff --git a/docs/geometry/artifacts/reasoning-m4/topology-firewall-proof.json b/docs/geometry/artifacts/reasoning-m4/topology-firewall-proof.jsonnew file mode 100644index 00000000..47d57565--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/topology-firewall-proof.json@@ -0,0 +1,21 @@+{+ "before": {+ "Vertices": 8,+ "Edges": 12,+ "Faces": 6,+ "Curves": 12,+ "Surfaces": 6+ },+ "after": {+ "Vertices": 8,+ "Edges": 12,+ "Faces": 6,+ "Curves": 12,+ "Surfaces": 6+ },+ "unchanged": true,+ "queryRelation": "Crossing",+ "witnessesAreAuthoritativeTrims": false,+ "resultContainsBrep": false,+ "law": "Generic numerical intersection may establish geometric evidence, but it does not author semantic topology."+}diff --git a/docs/geometry/artifacts/reasoning-m4/validation-report.json b/docs/geometry/artifacts/reasoning-m4/validation-report.jsonnew file mode 100644index 00000000..231945d2--- /dev/null+++ b/docs/geometry/artifacts/reasoning-m4/validation-report.json@@ -0,0 +1,37 @@+{+ "milestone": "AETHERIS-GEOMETRY-REASONING-M4",+ "endState": "Success",+ "restore": {+ "command": "dotnet restore Aetheris.slnx",+ "status": "passed"+ },+ "build": {+ "command": "dotnet build Aetheris.slnx -f net10.0 --no-restore /m:1",+ "status": "passed",+ "warnings": 0,+ "errors": 0+ },+ "tests": {+ "status": "passed",+ "projects": 13,+ "discoverableProjects": 12,+ "total": 2743,+ "passed": 2743,+ "failed": 0,+ "geometry": 46,+ "frictionLabDiscoverableTests": 0,+ "execution": "All *.Tests.csproj projects were run sequentially against the solution build. The initial solution-wide TRX runner exceeded its 120-second shell wrapper after recording 537 passes; sequential execution completed every project and produced the aggregate above."+ },+ "cli": {+ "command": "dotnet run --project Aetheris.CLI -- --help",+ "status": "passed"+ },+ "topologyFirewall": "passed",+ "constructiveConePlaneRegression": "passed",+ "determinism": "passed",+ "documentation": [+ "docs/geometry/intersection.md",+ "docs/geometry/reasoning.md",+ "docs/geometry/artifacts/reasoning-m4/intersection-audit.md"+ ]+}diff --git a/docs/geometry/intersection.md b/docs/geometry/intersection.mdnew file mode 100644index 00000000..c94a7247--- /dev/null+++ b/docs/geometry/intersection.md@@ -0,0 +1,52 @@+# Bounded intersection predicates++Status: AETHERIS-GEOMETRY-REASONING-M4++## Kernel law++> Generic numerical intersection may establish geometric evidence, but it does not author semantic topology.++`IntersectionQuery` observes bounded authored geometry. It does not create trim curves, split faces, change a BRep, run a Boolean, or confer export authority on a witness. Construction-specific algorithms remain separate when source intent already fixes the analytic family and expected topology; `TransverseConePlaneIntersection`, for example, remains the admitted cone/world-Z hyperbola construction.++## Public matrix++`IntersectionQuery.Between(a, b)` and `Between(a, b, policy)` support both operand orders for:++- bounded curve / plane;+- bounded patch / plane;+- bounded curve / bounded patch;+- bounded patch / bounded patch.++Curve/curve is intentionally deferred: it is optional in M4, and adding another shallow sampler would not improve the patch-focused evidence model.++`IntersectionPolicy` records linear, angular, and parameter tolerances; iteration and subdivision budgets; and the evidence preference. Every result returns the policy actually used, operand identities/provenance, bounded domains, ordered point witnesses and parameters, geometric residuals, statistics, typed diagnostics, and a plain-language provenance statement.++## Relation semantics++- `Disjoint`: the complete bounded domains are separated by the reported evidence. Certified signed-side or analytic scalar evidence is preferred; M3 distance convergence can provide tolerance-bounded separation.+- `Crossing`: strict opposite-side continuity evidence, or an interior near-zero candidate with transverse local differential evidence, has been established. A sampled policy never promotes its conclusion to `Certified`.+- `Touching`: a whole-domain one-sided argument and a compatible local tangent/contact observation are both available. A near-zero residual alone is insufficient.+- `Coincident`: structural identity or a bounded analytic structural-zero case is available. Numerical near-zero never earns this state.+- `Overlapping`: reserved for future certified partial-locus overlap. M4 does not infer it from dense sampling.+- `Unknown`: geometry is valid, but budget, unsupported interval operations, singular jets, ambiguous overlap, conflicting local evidence, or insufficient global evidence prevents an honest stronger conclusion.++`IsDefinitelyDisjoint` is a convenience projection over the richer result; it is not the primary API.++## Algorithms and evidence++Curve/plane reduces to `g(t) = dot(n, C(t) - p0)`. Analytic line endpoints give exact affine cases. Expression curves use the existing outward-rounded interval evaluator for strict separation and global one-sided evidence. Opposite strict signs plus continuity establish crossing; deterministic bisection produces a witness. A stationary near-zero candidate becomes `Touching` only with second-jet evidence and a whole-domain one-sided interval.++Patch/plane always invokes `SignedSideQuery`. Positive or negative maps to `Disjoint`; crossing maps to `Crossing`. When SignedSide remains inconclusive, its expression interval plus a tangent-plane contact candidate may establish tolerance-bounded touching. Otherwise the result remains `Unknown`.++Curve/patch and patch/patch first call M3 `ClosestPointQuery`. A stabilized distance above tolerance gates `Disjoint`. A near-zero candidate is then inspected with first jets. Curve tangent versus patch normal, or the two patch normals, supplies local transversality. A small deterministic interior candidate lattice prevents an arbitrary boundary minimum on a zero-distance locus from hiding an interior crossing. Compatible tangent planes remain a contact candidate and normally return `Unknown`; M4 does not trace a surface/surface intersection curve.++## Witness authority and future contact seam++`IntersectionWitness` is evidence only. `WitnessesAreAuthoritativeTrims` is permanently false, and the public result contains no BRep, trim, Boolean, face, edge, or mutation operation. No witness curves are emitted in M4, avoiding accidental trim reuse.++`ContactObservation` records tangent/normal and available second-jet observations. It deliberately does not expose multiplicity or contact order. A future `ContactClassification` / `ContactOrder` query can consume these observations without changing intersection authority.++## Tolerance and determinism++Tolerance is interpretation, not coordinate rounding. Residuals remain raw. Stable traversal orders are used for samples, subdivisions, bisection, candidate lattices, witnesses, and diagnostics. Budget exhaustion returns `Unknown` rather than a local answer that ignores unresolved regions.+diff --git a/docs/geometry/reasoning.md b/docs/geometry/reasoning.mdindex 927874a9..a446bd83 100644--- a/docs/geometry/reasoning.md+++ b/docs/geometry/reasoning.md@@ -1,6 +1,6 @@# Authored geometry reasoning-Status: AETHERIS-GEOMETRY-REASONING-M2+Status: AETHERIS-GEOMETRY-REASONING-M4## Architecture and authority@@ -93,15 +93,28 @@ Normal Aetheris code references `Aetheris.Geometry` directly. Forge extension auFinite analytic evaluation returns `ToleranceBounded`, never `Certified` merely because the source is an expression. Singular tangents, tiny normals, ill-conditioned metrics, unavailable second jets, and indeterminate principal directions remain explicit. See [differential-geometry.md](differential-geometry.md).+## Reasoning ladder++The public domain-neutral query ladder is now:++1. `SignedSideQuery`: whole-domain oriented side evidence for patch/plane.+2. `ClosestPointQuery`: bounded unsigned distance and candidate parameters for points, curves, and patches.+3. `CurvatureQuery`: local first/second-order differential observations.+4. `IntersectionQuery`: bounded relation evidence for curve/plane, patch/plane, curve/patch, and patch/patch.++Intersection composes the earlier layers. Patch/plane delegates whole-domain classification to SignedSide. Curve/patch and patch/patch use closest distance as the first gate, then jets only to classify a local candidate. Local differential evidence never silently becomes a global touching proof. See [intersection.md](intersection.md).+## Limitations-M2 does not add contact order, a generic tangency certificate, arbitrary trimmed parameter domains, generic curve/surface intersection, CAS, rational splines/NURBS, or theorem-specific vocabulary. Section and boundary procedural patches remain first-jet-only unless an honest second evaluator is supplied. No differential query materializes intersection curves or mutates topology.+M4 does not add contact order/multiplicity, arbitrary trimmed parameter domains, traced surface/surface intersection curves, CAS, rational splines/NURBS, or theorem-specific vocabulary. `Overlapping` is reserved but is not inferred numerically. Section and boundary procedural patches remain first-jet-only unless an honest second evaluator is supplied. No reasoning query materializes intersection curves or mutates topology.## Differential-geometry ladder- M0 established bounded patches and evidence-aware signed-side reasoning.- M1 adds bounded curves and a shared first-jet vocabulary.- M2 adds curve `P''`, patch `Puu/Puv/Pvv`, curvature, and sampled Panel G1/G2 evidence.-- M3 pressure is closest point/distance. Certified intersection and generic contact classification/order remain later independent query milestones; chronology may change with product pressure.+- M3 adds closest point/distance across authored points, curves, and patches.+- M4 adds bounded evidence-aware intersection predicates and preserves the topology firewall.+- A future milestone may add `ContactClassification` / `ContactOrder` as a separate query over local observations.M1 adds no generic curve intersection service. The constructive transverse-cone/world-Z hyperbola remains an admitted construction-specific analytic result; adapting its bounded trim does not grant it topology-authoring authority.diff --git a/tools/Aetheris.Geometry.M4Evidence/Aetheris.Geometry.M4Evidence.csproj b/tools/Aetheris.Geometry.M4Evidence/Aetheris.Geometry.M4Evidence.csprojnew file mode 100644index 00000000..fcb7f874--- /dev/null+++ b/tools/Aetheris.Geometry.M4Evidence/Aetheris.Geometry.M4Evidence.csproj@@ -0,0 +1,8 @@+<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" />+ <ProjectReference Include="..\..\Aetheris.Kernel.Core\Aetheris.Kernel.Core.csproj" />+ </ItemGroup>+</Project>diff --git a/tools/Aetheris.Geometry.M4Evidence/Program.cs b/tools/Aetheris.Geometry.M4Evidence/Program.csnew file mode 100644index 00000000..026268a4--- /dev/null+++ b/tools/Aetheris.Geometry.M4Evidence/Program.cs@@ -0,0 +1,150 @@+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.Brep;+using Aetheris.Kernel.Core.Geometry.Surfaces;+using Aetheris.Kernel.Core.Math;+using Aetheris.Surfacing;++var output = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..", "docs", "geometry", "artifacts", "reasoning-m4"));+Directory.CreateDirectory(output);+var json = new JsonSerializerOptions { WriteIndented = true }; json.Converters.Add(new JsonStringEnumConverter());+var z0 = new Plane3(Point3D.Origin, Direction3D.Create(new(0, 0, 1)));++var crossingLine = Line("crossing-line", new(0, 0, -1), new(0, 0, 1));+var disjointLine = Line("disjoint-line", new(-1, 0, 2), new(1, 0, 2));+var t = CurveExpression.T;+var tangentParabola = new BoundedParametricCurve3("tangent-parabola", new(-1, 1), new(+ CurveExpression.Multiply(CurveExpression.Length(1), t), CurveExpression.Length(0),+ CurveExpression.Multiply(CurveExpression.Length(1), CurveExpression.Power(t, 2))), "M4 scientific fixture");+Write("curve-plane-fixtures.json", new+{+ disjoint = IntersectionQuery.Between(disjointLine, z0),+ crossing = IntersectionQuery.Between(crossingLine, z0),+ tangent = IntersectionQuery.Between(tangentParabola, z0),+ structuralZero = IntersectionQuery.Between(Line("structural-zero", new(-1, 0, 0), new(1, 0, 0)), z0),+ unknown = IntersectionQuery.Between(BoundedParametricCurve3.Procedural("first-jet-only", new(-1, 1), x => (new(x, 0, x * x), new Vector3D(1, 0, 2 * x)), "M4 fixture"), z0)+});++var patchAbove = Graph("patch-above", SurfaceExpression.Length(2));+var patchCrossing = Graph("crossing-saddle", SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.U));+var tangentZ = SurfaceExpression.Add(+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.Power(SurfaceExpression.U, 2)),+ SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.Power(SurfaceExpression.V, 2)));+var patchTangent = Graph("tangent-paraboloid", tangentZ);+Write("patch-plane-fixtures.json", new+{+ disjoint = IntersectionQuery.Between(patchAbove, z0),+ crossing = IntersectionQuery.Between(patchCrossing, z0),+ tangent = IntersectionQuery.Between(patchTangent, z0),+ toleranceSensitivity = new+ {+ loose = IntersectionQuery.Between(Graph("near-plane-loose", SurfaceExpression.Length(5e-7)), z0),+ tight = IntersectionQuery.Between(Graph("near-plane-tight", SurfaceExpression.Length(5e-7)), z0, new() { LinearTolerance = 1e-8 })+ }+});++var horizontal = PlanePatch("horizontal", 0); var vertical = VerticalPatch("vertical");+Write("curve-patch-fixtures.json", new+{+ separated = IntersectionQuery.Between(disjointLine, horizontal),+ transverse = IntersectionQuery.Between(crossingLine, horizontal),+ nearContact = IntersectionQuery.Between(Line("in-plane", new(-.5, 0, 0), new(.5, 0, 0)), horizontal),+ budgetLimited = IntersectionQuery.Between(crossingLine, horizontal, new IntersectionPolicy { SubdivisionBudget = 16 })+});+Write("patch-patch-fixtures.json", new+{+ separated = IntersectionQuery.Between(horizontal, PlanePatch("parallel-gap", 2)),+ transverse = IntersectionQuery.Between(horizontal, vertical),+ tangentCompatible = IntersectionQuery.Between(horizontal, PlanePatch("compatible", 0)),+ structurallyCoincident = IntersectionQuery.Between(horizontal, PlanePatch("horizontal", 0)),+ numericalNearZero = IntersectionQuery.Between(horizontal, PlanePatch("near", 5e-7)),+ budgetLimited = IntersectionQuery.Between(horizontal, vertical, new IntersectionPolicy { SubdivisionBudget = 16 })+});++var panel = PanelFactory.FromParametric(new ParametricSurfaceIr("panel", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), GraphExpression(SurfaceExpression.Length(3)), "cad:M4-panel")).Panel!;+var panelGap = PanelFactory.FromParametric(new ParametricSurfaceIr("panel-gap", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), GraphExpression(SurfaceExpression.Length(5)), "cad:M4-panel-gap")).Panel!;+var panelCrossing = PanelFactory.FromParametric(new ParametricSurfaceIr("panel-crossing", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), GraphExpression(SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.U)), "cad:M4-panel-crossing")).Panel!;+var panelTangent = PanelFactory.FromParametric(new ParametricSurfaceIr("panel-tangent", SurfaceConstructionKind.ParametricSurface,+ new(new(-1, 1), new(-1, 1)), GraphExpression(tangentZ), "cad:M4-panel-tangent")).Panel!;+Write("panel-cad-dogfood.json", new+{+ panelPlane = IntersectionQuery.Between(panel.AuthoredPatch, z0),+ panelPanelGap = IntersectionQuery.Between(panel.AuthoredPatch, panelGap.AuthoredPatch),+ panelPlaneCrossing = IntersectionQuery.Between(panelCrossing.AuthoredPatch, z0),+ panelPlaneTangent = IntersectionQuery.Between(panelTangent.AuthoredPatch, z0)+});++var body = BrepPrimitives.CreateBox(4, 6, 8).Value;+var before = Counts(body); var firewallQuery = IntersectionQuery.Between(crossingLine, horizontal); var after = Counts(body);+Write("topology-firewall-proof.json", new+{+ before, after, unchanged = before == after, queryRelation = firewallQuery.Relation,+ witnessesAreAuthoritativeTrims = firewallQuery.WitnessesAreAuthoritativeTrims,+ resultContainsBrep = firewallQuery.GetType().GetProperties().Any(p => p.PropertyType == typeof(BrepBody)),+ law = "Generic numerical intersection may establish geometric evidence, but it does not author semantic topology."+});+var cone = new ConeSurface(Point3D.Origin, Direction3D.Create(new(1, 0, 0)), double.Pi / 4, Direction3D.Create(new(0, 0, 1)));+var coneSection = TransverseConePlaneIntersection.IntersectWorldZ(cone, 2);+Write("bounded-constructive-regression.json", new { success = coneSection.IsSuccess, resultFamily = coneSection.Value.GetType().Name, unchangedRoute = "TransverseConePlaneIntersection.IntersectWorldZ", genericQueryReplacement = false });++Write("api-architecture.json", new+{+ owner = "Aetheris.Geometry", matrix = new[] { "Curve-Plane", "Patch-Plane", "Curve-Patch", "Patch-Patch" },+ relationStates = Enum.GetNames<IntersectionRelation>(), evidenceClasses = Enum.GetNames<PredicateEvidenceKind>(),+ policy = IntersectionPolicy.Default,+ resultFields = typeof(IntersectionResult).GetProperties().Select(p => p.Name).ToArray(),+ witnessFields = typeof(IntersectionWitness).GetProperties().Select(p => p.Name).ToArray(),+ witnessAuthority = "EvidenceOnly; NonAuthoritative; NonExportableAsTrim",+ futureSeam = "ContactClassification / ContactOrder (not implemented)"+});++var operations = new (string Name, Func<IntersectionResult> Run)[]+{+ ("curve-plane", () => IntersectionQuery.Between(crossingLine, z0)),+ ("patch-plane", () => IntersectionQuery.Between(patchCrossing, z0)),+ ("curve-patch", () => IntersectionQuery.Between(crossingLine, horizontal)),+ ("patch-patch", () => IntersectionQuery.Between(horizontal, vertical))+};+var performance = new List<object>();+foreach (var operation in operations)+{+ for (var i = 0; i < 3; i++) operation.Run(); const int count = 25; var watch = Stopwatch.StartNew();+ IntersectionResult? last = null; for (var i = 0; i < count; i++) last = operation.Run(); watch.Stop();+ performance.Add(new { operation.Name, iterations = count, elapsedMilliseconds = watch.Elapsed.TotalMilliseconds,+ nanosecondsPerQuery = watch.Elapsed.TotalNanoseconds / count, last!.Statistics });+}+Write("performance.json", new { note = "Calibration only; no optimization campaign.", operations = performance });++var deterministicCases = new Dictionary<string, Func<IntersectionResult>>+{+ ["curve-plane"] = () => IntersectionQuery.Between(crossingLine, z0), ["patch-plane"] = () => IntersectionQuery.Between(patchCrossing, z0),+ ["curve-patch"] = () => IntersectionQuery.Between(crossingLine, horizontal), ["patch-patch"] = () => IntersectionQuery.Between(horizontal, vertical)+};+var reports = deterministicCases.OrderBy(x => x.Key, StringComparer.Ordinal).Select(pair =>+{+ var first = JsonSerializer.Serialize(pair.Value(), json); var second = JsonSerializer.Serialize(pair.Value(), json);+ return new { name = pair.Key, stable = first == second, sha256 = Sha(first) };+}).ToArray();+Write("deterministic-hashes.json", new { algorithm = "SHA-256", reports });+Console.WriteLine(JsonSerializer.Serialize(new { output, generated = Directory.GetFiles(output).Select(Path.GetFileName).Order().ToArray() }, json));++void Write(string name, object value) => File.WriteAllText(Path.Combine(output, name), JsonSerializer.Serialize(value, json) + Environment.NewLine, new UTF8Encoding(false));+string Sha(string value) => Convert.ToHexString(SHA256.HashData(Encoding.UTF8.GetBytes(value))).ToLowerInvariant();+TopologyCounts Counts(BrepBody b) => new(b.Topology.Vertices.Count(), b.Topology.Edges.Count(), b.Topology.Faces.Count(), b.Geometry.Curves.Count(), b.Geometry.Surfaces.Count());+BoundedParametricCurve3 Line(string id, Point3D a, Point3D b) => BoundedParametricCurve3.LineSegment(id, a, b, "M4 evidence");+SurfacePointExpression GraphExpression(SurfaceScalarExpression z) => new(SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.U), SurfaceExpression.Multiply(SurfaceExpression.Length(1), SurfaceExpression.V), z);+BoundedParametricPatch3 Graph(string id, SurfaceScalarExpression z) => new(id, new(new(-1, 1), new(-1, 1)), GraphExpression(z), "M4 evidence");+BoundedParametricPatch3 PlanePatch(string id, double z) => BoundedParametricPatch3.Procedural(id, new(new(-1, 1), new(-1, 1)),+ (u, v) => new(new(u, v, z), new(1, 0, 0), new(0, 1, 0), Direction3D.Create(new(0, 0, 1)), false),+ (u, v) => new(new(u, v, z), new(1, 0, 0), new(0, 1, 0), new(0, 0, 0), new(0, 0, 0), new(0, 0, 0), DifferentialSingularityKind.Regular), "M4 evidence");+BoundedParametricPatch3 VerticalPatch(string id) => BoundedParametricPatch3.Procedural(id, new(new(-1, 1), new(-1, 1)),+ (u, v) => new(new(u, 0, v), new(1, 0, 0), new(0, 0, 1), Direction3D.Create(new(0, -1, 0)), false), "M4 evidence");++internal sealed record TopologyCounts(int Vertices, int Edges, int Faces, int Curves, int Surfaces);