Skip to content

gosper_encode

function gosper_encode(
point,
level,
size,
orientation?): number;

Defined in: gosper.ts:171

Maps a point to its position along the Gosper curve.

The island is centred on the origin, so translate your data there first. Points outside it return -1 rather than aliasing onto an interior cell.

ParameterTypeDefault valueDescription
pointPointundefinedThe point to index.
levelnumberundefinedCurve level; the curve has 7^level cells.
sizenumberundefinedLevel-0 hexagon size, from gosper_size.
orientationHexOrientation"flat"Which way up the hexagons sit. Defaults to "flat".

number

The curve index in [0, 7^level), or -1 if outside the island.