Resources Numerical accuracy Calculation policy

Linework checks for linked landscape objects

Checks a line or outline taken from other linework before a landscape object uses it, and detects when that source has moved.

How the precision is kept

Points are copied as 64-bit numbers without rounding. The checks use fixed absolute tolerances: repeated points within 1e-9 are dropped and an outline is closed when its ends are within 1e-6. A change of the source is detected from a hash of the coordinates rounded to 1e-6, so a move smaller than that is not followed.

Calculations under this policy

3 calculations in 1 source file. The code is read from the released app when this page loads. It is the calculation people run, not a copy kept for this page.

landscape/links.js CivilCraft 0.8.1 64-bit 3 calculations Reviewed

Tests bin/test-landscape.mjs

In detail

Method
Repeated points are removed, an outline is closed, and every pair of non-neighboring edges is tested for a proper crossing with segCross from areas.js. The fingerprint is FNV-1a over the coordinates rounded to 1e-6, as the file header says.
Number types
64-bit numbers; a 32-bit integer hash for the fingerprint only.
Tolerances
Repeated point: distance of 1e-9 or less, absolute. Closing tolerance 1e-6, absolute. A crossing counts only when it lies between 1e-9 and 1 − 1e-9 along both edges. Coordinates beyond ±1e9 are refused. Fingerprint resolution 1e-6.
Limits
Lines with more than 2000 points are not tested for self-crossing here.

Approach: 64-bit, direct

Every value is a 64-bit number from input to result. Formulas are closed form or a direct solve, and every comparison uses a stated tolerance.

Every policy that takes this approach