Hexagonal and Rectangular PCB Grids: How to Convert
Converting between hexagonal and rectangular PCB grids lets you translate hole or pad locations from one layout to another while preserving their physical positions. You will need the grid pitch, the hex-grid orientation, an origin, and a clear coordinate convention; the formulas below convert coordinates, not footprints or electrical connections.
What You’ll Need
- The source layout’s grid pitch and coordinate units, such as millimetres or inches.
- The hex grid’s orientation: pointy-top or flat-top, and whether its rows or columns are staggered.
- A shared origin and an agreed direction for positive X and Y.
- A calculator or spreadsheet for the coordinate arithmetic, plus PCB CAD software to inspect the converted placement.
- The target rectangular grid pitch, if locations must snap to a particular rectangular grid.
Step-by-Step
- Choose a coordinate convention. Measure all positions from the same origin, usually a board corner or a defined datum. Decide whether X increases to the right and Y upward or downward. PCB software often displays Y downward, while mathematics commonly uses Y upward; convert the sign if necessary. Keep all measurements in one unit.
- Identify what “hexagonal grid” means in your layout. A common hex arrangement has nearest-neighbour spacing s in six directions. For a pointy-top layout with vertical columns and alternating horizontal offsets, the horizontal column pitch is √3s, the vertical row pitch is 1.5s, and every other column is offset vertically by 0.5s. A flat-top arrangement is the rotated counterpart. Do not assume the CAD grid’s entered spacing is the nearest-neighbour distance: check how that tool defines its X and Y steps.
- Record each hex-grid location as integer indices. Assign each position a column index q and row index r, starting at zero or another consistent reference. For the pointy-top convention above, the physical coordinates are:
x = x₀ + √3s(q + r/2)y = y₀ + 1.5s r
Here (x₀, y₀) is the physical origin. This is an axial-coordinate convention; it works for negative indices too. If your grid is flat-top or uses a different offset convention, rotate or adapt the mapping rather than applying this formula unchanged. - Convert hex coordinates to physical X and Y. Substitute the pitch and each pair of indices into the equations. For example, with s = 2 mm, x₀ = 0, y₀ = 0, and location (q, r) = (1, 1), the result is x = √3 × 2 × 1.5 ≈ 5.196 mm and y = 1.5 × 2 × 1 = 3 mm. Keep full precision during calculations; round only when your CAD tool requires it.
- Map physical coordinates onto the rectangular grid. If the target grid spacing is gₓ horizontally and gᵧ vertically, calculate rectangular indices as i = round((x − x₀)/gₓ) and j = round((y − y₀)/gᵧ). The snapped position is x′ = x₀ + i gₓ, y′ = y₀ + j gᵧ. If the target uses equal spacing, set gₓ = gᵧ. If preserving exact positions matters more than snapping, use the physical coordinates directly instead of rounding to grid indices.
- Measure the snap error before accepting the conversion. For each point, calculate Δx = x′ − x, Δy = y′ − y, and total displacement √(Δx² + Δy²). Compare it with the placement tolerance and nearby clearance requirements for your design. A rectangular grid generally cannot represent every hex-grid position exactly, so snapping may move pads or holes.
- Convert back when needed. For the same pointy-top convention, recover the hex indices from physical coordinates using r = (y − y₀)/(1.5s) and q = (x − x₀)/(√3s) − r/2. These are continuous indices; round to integers only if you intend to assign the point to the nearest hex site. Check the resulting physical position and error just as you did for rectangular snapping.
- Transfer the coordinates into the PCB layout and verify them. Use the CAD tool’s coordinate entry, placement table, script, or import feature, following its own axis and unit conventions. Check several known points—including an origin point, an unshifted point, and a staggered point—then inspect the entire board at useful zoom levels. Confirm pad numbering, footprint rotation, board outline, clearances, and electrical connectivity separately; coordinate conversion does not validate these.
Common Mistakes
- Mixing pitch definitions. The nearest-neighbour distance s is not the same as the horizontal and vertical steps in a staggered hex grid. Substituting one for another distorts the layout.
- Using the wrong orientation. Pointy-top and flat-top grids swap the direction of the stagger. Confirm which axis has alternating offsets before calculating.
- Rounding too early. Rounding intermediate coordinates can accumulate errors across a board. Keep adequate precision, then round once to the CAD tool’s supported precision.
- Snapping without checking displacement. Nearest-grid rounding can move a feature by a meaningful amount, especially when the rectangular grid is coarse.
- Ignoring the origin or Y direction. A different datum or inverted Y axis can mirror or shift the converted pattern even when the pitch is correct.
Tips
- Make a small test pattern with several adjacent sites before converting a complete board.
- Keep a table with source indices, physical coordinates, snapped coordinates, and displacement. This makes unusual shifts easy to find.
- Use a rectangular pitch that divides the important dimensions cleanly when exact placement is required. Otherwise, preserve physical coordinates and treat the grid as a visual aid.
- Check the CAD application’s coordinate precision and whether grid snapping is active during placement or import.
- Save a copy of the original layout before bulk-moving or importing converted positions.
Troubleshooting
The pattern looks stretched or compressed: Recheck whether your input is nearest-neighbour pitch or an axis step, and verify that the same units were used throughout. Test the formula with two neighbouring sites whose separation you know.
The stagger alternates in the wrong direction: Your grid may use the flat-top convention, stagger rows rather than columns, or define indices differently. Identify two adjacent rows and columns from the source, then derive the mapping from their measured positions instead of guessing.
The converted pattern is mirrored or displaced: Compare the origin and positive-axis directions in the source and target. Flip the Y sign or adjust the origin only when the board coordinate conventions require it; do not alter the pitch to compensate.
Some converted points do not land on the target grid: This is expected when the grids are not commensurate. Decide whether to keep exact physical coordinates, accept and document the snap error, or choose a finer rectangular grid. Do not silently force a coarse snap where pad alignment or clearances matter.
CAD coordinates differ from your spreadsheet: Check whether the application displays mils or millimetres, uses a different origin, rounds on entry, or applies snapping. Enter one test coordinate manually and compare the displayed location before importing the full set.
Frequently Asked Questions
Can a hexagonal grid be converted exactly to a rectangular grid?
Only some positions align exactly. In general, the two lattices have different geometry, so rectangular snapping can move locations. Keeping decimal physical coordinates avoids that snap but may leave points off-grid.
What does the hex pitch mean?
In the formulas here, s is the centre-to-centre distance between neighbouring sites. Some CAD tools instead describe grid spacing by axis increments, so confirm the tool’s definition.
Do these equations work for a flat-top grid?
Not as written: they assume a pointy-top layout with vertically progressing rows and alternating column offsets. A flat-top layout is rotated, so use the corresponding rotated mapping or transform the coordinates by 90 degrees.
Should I round coordinates to whole millimetres or mils?
No, not unless the design requirement calls for it. Use the CAD tool’s supported precision and round only as much as necessary; arbitrary rounding changes physical placement.
Does converting coordinates preserve electrical connections?
No. It only transforms positions. Verify nets, pad numbers, rotations, clearances, and connectivity in the PCB design after conversion.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.