Skip to content

spatial-monorepo


spatial-monorepo / editor/src / solveHomography

Function: solveHomography()

solveHomography(srcPoints, dstPoints): number[]

Defined in: packages/editor/src/solveHomography.ts:290

Solve for the 3×3 homography H (row-major, normalized so H[8] = 1) mapping srcPoints → dstPoints using the DLT algorithm.

Both point sets are Hartley-normalised (centroid at origin, mean distance √2) before the DLT constraint matrix is built; the resulting eigenvector is denormalised back to the original coordinate spaces. This keeps A^T A well-conditioned even when srcPoints are image pixels (0..thousands) and dstPoints are lng/lat degrees (deltas ~1e-4).

Parameters

srcPoints

[number, number][]

at least 4 [x, y] points in image space

dstPoints

[number, number][]

corresponding [x', y'] points in map space

Returns

number[]

9-element row-major homography matrix, normalized so result[8] === 1

Throws

Error if fewer than 4 point pairs are provided, or if srcPoints or dstPoints are degenerate (collinear or coincident — no unique homography exists)

Released under commercial licensing.