Mihir Raj RathoreMechanical engineer · M.Eng.
Domain D → Engineering automation

Geometric Clearance Inspector

Engineering automation · independent Python prototype

An independent Python prototype for screening geometric relationships in a synthetic assembly and generating a structured inspection record.

Independent project · Synthetic geometry Not CAD-kernel geometry · Screening prototype
ABCDCLOSE
Fig. D1.Synthetic assembly, invented rectangles. Lengths in arbitrary units (u). Live: it follows the controls below.
Live readout
Inspected pair
A · Base plate ↔ B · Bracket
Signed separation
+1.50 u
Screening threshold
2.50 u
Screening state
CLOSE

The gap is within the screening threshold.

01 · The engineering question

How can a repetitive geometric check be made explicit, repeatable and inspectable?

  1. 01Geometry4 components · uInvented rectangles with a position and a rotation.
  2. 02Relationships = +1.50 uSigned separation of the chosen pair.
  3. 03Screeningt = 2.50 u → CLOSECompare with a threshold and assign a state.
  4. 04ReportINS-515DE53DA structured record of the run.
02 · Change the geometry

Move the components. The check runs again.

You are operating a synthetic demonstration. The values are arbitrary and do not come from any real assembly.

Fig. D2 · Synthetic assemblySynthetic · u
ABCDCLOSE · s = +1.50 u10 u
Controls
Component to move

A · Base plate does not move.

+0.0 u
+0.0 u
+0°
Inspected pair
2.50 u
Inspection mode

The interactive inspector needs JavaScript. The figures on this page show the default state of the synthetic assembly. The Python source in the project folder runs the same logic from the command line.

03 · Inspect the relationship

Separation, proximity or intersection

The view is fitted to the inspected pair. You set the state with the controls above. It is not a finding.

Fig. D3 · Inspected pairSynthetic · u
ABCDCLOSE · s = +1.50 u
CLEARANCE · separationThe gap is larger than the threshold.
CLOSE · proximityThe gap is zero or small, up to and including the threshold.
INTERACTION · intersectionThe shapes intersect. s is the negative overlap depth.
04 · Screening logic

geometry → relationship → threshold → screening state

The values below are computed from the current geometry. Nothing is pre-scripted.

  1. 01
    Separating-axis testProject both shapes on the 8 edge normals. Largest gap along a test axis: 1.50 u.Separating axis found: the shapes are separated.
  2. 02
    Signed separation sseparated: s = + nearest vertex-to-edge distance · intersecting: s = − smallest overlaps = +1.50 u (gap)
  3. 03
    Compare with threshold t = 2.50 u
    s > tCLEARANCE
    0 ≤ s ≤ tCLOSE
    s < 0INTERACTION
  4. 04
    Screening stateCLOSE
05 · Generated inspection record

Every run produces a structured record

The record changes when the geometry changes. Run identifier: a fingerprint of the inputs, so the same inputs give the same identifier.

Record view
Screening result — synthetic assemblySynthetic
Inspection IDINS-515DE53D
Component AA · Base plate
Component BB · Bracket
Geometric stateSEPARATED
Screening threshold2.500 u
Calculated relationship+1.500 u (gap)
Screening resultCLOSE
Run identifier515DE53D

Synthetic demonstration. Screening prototype on invented 2D geometry. Not CAD-kernel geometry.

06 · Python architecture

Five small stages, one file each

The Python package is the reference implementation. This page runs a JavaScript port of the same algorithm so it works in a browser. The port is compared with the Python results on generated test cases (372 cases, same inputs, same outputs within 1e-9).

  1. 01Geometry inputscenario.py
    Component, HOME
  2. 02Transformationgeometry.py
    polygon()
  3. 03Geometric screeningscreening.py
    relationship()
  4. 04Threshold logicscreening.py
    classify()
  5. 05Inspection recordreport.py
    build_record()
clearance_inspector/screening.py · excerptPython
def _sat(a, b):
    """Return (separating_axis_found, smallest projection overlap over all axes)."""
    smallest = np.inf
    for n in np.vstack([_normals(a), _normals(b)]):
        pa, pb = a @ n, b @ n
        overlap = min(pa.max(), pb.max()) - max(pa.min(), pb.min())
        smallest = min(smallest, overlap)
    return smallest <= EPS, float(smallest)


def classify(signed_separation: float, threshold: float) -> str:
    """Threshold comparison. Boundary values: s == 0 and s == t are CLOSE."""
    if signed_separation < 0:
        return "INTERACTION"
    if signed_separation <= threshold:
        return "CLOSE"
    return "CLEARANCE"

Run one inspection from the command line:

python -m clearance_inspector --pair A-B --threshold 2.5 --move B 0 1.5 0
07 · Engineering limits

What this prototype does and does not do

What it does
  • Takes four invented rectangles with a position and a rotation.
  • Computes a signed separation for a chosen pair, using the separating-axis test and an exact vertex-to-edge distance.
  • Compares it with a threshold you set and assigns CLEARANCE, CLOSE or INTERACTION.
  • Writes a structured inspection record for every run.
  • Gives the same result in Python and in the browser port.
What it does not do
  • Simplified synthetic geometry: 2D rectangles only.
  • Screening logic, not full CAD geometry.
  • No tolerance-stack certification.
  • No production release.
  • No physical validation.
  • No proprietary data.
  • No replacement for a commercial CAD kernel.
  • Overlap depth is a minimum translation distance, not an overlap volume.
  • The units are arbitrary. No value on this page describes a real part.