DEV Community

Cover image for Laser Hat Patch DXF/SVG Geometry: Constant-Arc-Length Stitch Holes, Bowtie-Free Offsets & Hexagonal Sheet Packing in TypeScript
CutPath CAD
CutPath CAD

Posted on Originally published at cutpathcad.com

Laser Hat Patch DXF/SVG Geometry: Constant-Arc-Length Stitch Holes, Bowtie-Free Offsets & Hexagonal Sheet Packing in TypeScript

Laser-cutting leatherette hat patches looks deceptively simple until you actually try to produce 200 Richardson 112 trucker-hat patches on a CO2 or diode laser without wasting sheets, blowing out stitch corners, or having parts drop through honeycomb slats mid-job.

When we built CutPath CAD's browser-native Free Laser Hat Patch & Stitch-Hole DXF/SVG Generator, we found that naive vector generation fails in four very specific geometric ways: crown-curvature oversizing, closing-corner stitch seam gaps, concave self-intersection ("bowties") during inward polygon offsetting, and naive rectangular sheet nesting that leaves 15–20% of a $13.50 leatherette sheet on the scrap table.

Here is the exact computational geometry and TypeScript architecture we use to generate 100%-closed AutoCAD R12 (AC1009) DXF and color-coded LightBurn/xTool SVG files directly in the browser.


1. The Richardson 112 Crown Geometry Constraint

A standard 6-panel mid-profile trucker cap (Richardson 112, Yupoong 6606, Otto 31-069) has a compound-curved front buckram panel. A rigid polyurethane (PU) leatherette patch backed with heat-activated adhesive (such as Lonestar Adhesive or JDS Industries 12"×24" sheets) cannot stretch in two axes simultaneously.

If a flat patch exceeds roughly 4.00" wide × 2.50" tall, the corners lift or buckle during heat pressing on a curved hat platen. That physical envelope drives four industry-standard production footprints:

Patch Style Production Footprint Crown Fit
Classic Trucker Rectangle 3.50" × 2.25" (88.9 × 57.15 mm) Centered inside 4.00" × 2.50" safe zone
Elongated Trucker Hexagon 3.25" × 2.25" (82.55 × 57.15 mm) Tapered corners hug crown curvature
Beanie / Dad-Hat Medallion 2.50" Ø (63.5 mm circle) Works on cuffed beanies and low-profile caps
Heritage Shield Crest 2.75" × 2.50" (69.85 × 63.5 mm) Maximum vertical presence without top-seam buckling

Modeling this safe envelope directly in the CAD preview prevents makers from designing a 4.5" wide patch that looks great on screen and ruins a blank hat on the press.


2. Two Bugs Every Naive CAD Script Hits on Stitch Borders

Bug 1: Uneven Seam Gaps at Vertex 0

Most SVG/DXF stitch scripts step along a perimeter using a fixed targetPitch (for example, 4.50 mm). Unless the total perimeter L happens to be an exact integer multiple of 4.50 mm, the final stitch lands at L mod 4.50 from vertex 0—leaving either a glaring double gap or two colliding holes at the closing corner.

The fix is constant-arc-length resampling:

  1. Measure the exact closed polyline perimeter L.
  2. Compute the integer stitch count N = Math.max(8, Math.round(L / targetPitch)).
  3. Recompute the exact pitch exactPitch = L / N.
  4. Sample both position (x, y) and smooth unit tangent (tx, ty) at s_i = i * exactPitch for i = 0 .. N - 1.
export interface Pt { x: number; y: number; }
export interface StitchSample { x: number; y: number; tx: number; ty: number; }

export function sampleConstantArcLength(
  closedLoop: Pt[],
  targetPitchMm: number
): { samples: StitchSample[]; exactPitchMm: number; perimeterMm: number } {
  const n = closedLoop.length;
  const cumLen: number[] = [0];
  for (let i = 0; i < n; i++) {
    const a = closedLoop[i];
    const b = closedLoop[(i + 1) % n];
    cumLen.push(cumLen[i] + Math.hypot(b.x - a.x, b.y - a.y));
  }

  const perimeterMm = cumLen[n];
  const count = Math.max(8, Math.round(perimeterMm / targetPitchMm));
  const exactPitchMm = perimeterMm / count;
  const samples: StitchSample[] = [];

  let seg = 0;
  for (let i = 0; i < count; i++) {
    const s = i * exactPitchMm;
    while (seg < n - 1 && cumLen[seg + 1] < s) seg++;

    const segStart = cumLen[seg];
    const segLen = Math.max(1e-9, cumLen[seg + 1] - segStart);
    const t = (s - segStart) / segLen;

    const a = closedLoop[seg];
    const b = closedLoop[(seg + 1) % n];
    const dx = b.x - a.x;
    const dy = b.y - a.y;
    const len = Math.max(1e-9, Math.hypot(dx, dy));

    samples.push({
      x: a.x + dx * t,
      y: a.y + dy * t,
      tx: dx / len,
      ty: dy / len,
    });
  }

  return { samples, exactPitchMm, perimeterMm };
}
Enter fullscreen mode Exit fullscreen mode

Because every sample carries its unit tangent (tx, ty), the exact same pipeline drives all three stitch styles with 0.00 mm seam mismatch:

  • Sew-on holes: emit a circle of diameter Ø1.2 mm centered at (x, y).
  • Hand saddle-stitch chisel slits: emit a 2.4 mm segment from (x - 1.2*tx, y - 1.2*ty) to (x + 1.2*tx, y + 1.2*ty) (or angled at 30°–45° to the tangent for slanted pricking-iron aesthetics).
  • Faux engraved dashes: emit a 2.2 mm line segment along (tx, ty) on an engrave-only layer for heat-press patches.

Bug 2: Concave Self-Intersection ("Bowties") on Inward Polygon Offsets

A classic mistake when building the inner stitch track (inset by 3.2–4.5 mm from the outer cut edge) is to generate the rounded outer polygon first, and then offset its dense arc vertices inward along vertex normals.

Whenever the corner fillet radius R is smaller than edgeInsetMm, the offset curve passes past the center of curvature and inverts into a self-intersecting bowtie loop at every corner.

The clean, zero-bowtie solution is offset-before-fillet:

  1. Construct the sharp straight-edge control polygon first.
  2. Offset each straight edge inward by edgeInsetMm and intersect adjacent offset lines (miter join), or scale analytically for smooth parametric curves like circles, ovals, and shield crests.
  3. Apply circular corner fillets after offsetting, using innerRadius = Math.max(0, cornerRadius - edgeInsetMm).

For concave shapes—such as a western notched-corner ticket patch—computing the notch arcs directly from the inset frame guarantees strictly positive signed area and zero self-intersections across all 8 patch shapes.


3. Collision-Free Hexagonal Honeycomb Packing for 12"×24" Sheets

Laserable leatherette is sold in 12" × 24" (304.8 × 609.6 mm) sheets, typically around $13.50 each. Dropping circular or octagonal patches onto a naive rectangular grid wastes massive area in the interstitial pockets.

For circular patches of diameter D with laser clearance gap g, alternating odd rows horizontally by (D + g) / 2 compresses the vertical row pitch from D + g down to the exact hexagonal packing height:

export interface SheetPlacement { x: number; y: number; row: number; col: number; }

export function packHexagonalCircles(
  sheetW: number,
  sheetH: number,
  margin: number,
  diameter: number,
  gap: number
): SheetPlacement[] {
  const stepX = diameter + gap;
  const stepY = Math.sqrt(stepX * stepX - (stepX / 2) ** 2); // stepX * sqrt(3)/2
  const r = diameter / 2;
  const placements: SheetPlacement[] = [];

  let row = 0;
  for (let cy = margin + r; cy <= sheetH - margin - r + 1e-6; cy += stepY, row++) {
    const xOffset = row % 2 === 1 ? stepX / 2 : 0;
    let col = 0;
    for (let cx = margin + r + xOffset; cx <= sheetW - margin - r + 1e-6; cx += stepX, col++) {
      placements.push({ x: cx, y: cy, row, col });
    }
  }
  return placements;
}
Enter fullscreen mode Exit fullscreen mode

On a standard 12"×24" sheet with 4 mm edge margin and 3 mm cut gap:

  • Rectangular grid (2.5" beanie circles): 36 patches ($0.38/patch)
  • Hexagonal honeycomb stagger: 43 patches ($0.31/patch, 73.2% area utilization)—7 extra patches from the exact same sheet!

There is one subtle geometric trap with elongated flat-cap hexagons (like the 3.25"×2.25" trucker hexagon): if the horizontal top/bottom flat half-width flatHalf exceeds stepX / 2, staggering odd rows vertically causes adjacent flat caps to collide. Our packing solver explicitly checks flatHalf > stepX / 2 and falls back to rectangular pitch when needed, backed by an automated point-in-polygon collision check across all 8 shapes.


4. Strict AutoCAD R12 (AC1009) + Deterministic LightBurn Cut-Order

Even with perfect geometry, cut order matters physically on a honeycomb laser bed. If the laser cuts the outer patch silhouette first, the patch can tilt, shift under air assist, or drop slightly between honeycomb fins before the inner stitch holes fire—ruining alignment.

Both our strict AutoCAD R12 (AC1009) DXF and 1:1 physical-mm SVG enforce deterministic cut order through explicit layer separation:

  1. STITCH_HOLES (#0284C7 cyan): Cut Ø1.2 mm sew-on holes or 2.4 mm chisel slits first while the sheet is still rigid and flat.
  2. ENGRAVE_STITCH (#2563EB blue): Score/engrave faux stitch dashes for heat-press patches.
  3. CUT_OUTER (#DC2626 red): Expanded outward by +kerf / 2 (default +0.075 mm per side for a 0.15 mm CO2 laser kerf) and executed last so the finished patch drops cleanly at exact nominal dimensions.

Every closed contour is emitted as a single closed POLYLINE / SEQEND loop with zero duplicate segments or open endpoints—verified at 100/100 · 0 OPEN readiness before download.

(Safety note: always cut PVC-free polyurethane laserable leatherette or vegetable-tanned leather—never PVC/vinyl faux leather, which releases corrosive HCl gas.)


Try It Free in Your Browser

You can test all 8 patch shapes, constant-arc-length stitch borders, kerf compensation, and live 12"×24" sheet packing with per-patch cost math—no signup required:

Top comments (0)