Table of Contents

Method FindNearestPointOnHexGrid

Namespace
Pinwheel.Vista
Assembly
Pinwheel.Vista.Runtime.dll

FindNearestPointOnHexGrid(Vector2, float, Orientation)

Finds the nearest snapped center position on a hex grid for an arbitrary point.

public static Vector2 FindNearestPointOnHexGrid(Vector2 p, float hexRadius, Hexagon2D.Orientation hexOrientation)

Parameters

p Vector2

The point to snap.

hexRadius float

The radius of the target hex grid cells.

hexOrientation Hexagon2D.Orientation

The orientation of the target hex grid.

Returns

Vector2

The closest candidate center among the four neighboring snap solutions sampled around p.

Remarks

The method samples four offset positions around the query point, snaps each one independently, then returns the closest result. This avoids some orientation-dependent edge cases that arise when snapping directly once.