Destination point
The point reached from start after distance metres along the great circle leaving it at bearing degrees clockwise from north, on a sphere of radius R = 6,371,008.8 m, as {lat, lon} in 1e-7 degrees. bearing must be finite in −360 to 360 and distance finite in 0 to 20,000,000, else an error. With φ1 = rad(start.lat), λ1 = rad(start.lon), θ = rad(bearing), δ = distance ÷ R: φ2 = asin(clamp(sin φ1 × cos δ + cos φ1 × sin δ × cos θ, −1, 1)); λ2 = λ1 + atan2(sin θ × sin δ × cos φ1, cos δ − sin φ1 × sin φ2), with sin φ2 the sine of φ2; lat = round(deg(φ2) × 1e7); lon = round(((deg(λ2) + 540) % 360 − 180) × 1e7), % being the remainder truncated toward zero (C fmod), and a lon of 1,800,000,000 becomes −1,800,000,000. A point is {lat, lon} in degrees; it is an error unless both are finite with −90 ≤ lat ≤ 90 and −180 ≤ lon ≤ 180 (NaN and ±Infinity are errors). rad(v) = v × π ÷ 180 and deg(v) = v × 180 ÷ π, left to right, with π the binary64 nearest π. Arithmetic is IEEE 754 binary64, each operation rounded to nearest-even and evaluated in exactly the order written (left to right; no fused multiply-add). sin, cos, tan, asin, atan, atan2, exp and ln are the platform's own: the result is an integer, round half away from zero, so any libm accurate to a few ulps gives the same answer except within a hair of a rounding boundary.
From your terminal
npm i -g https://liberas.dev/cli/liberas.tgzexport LIBERAS_URL=https://liberas.devliberas init geo-destination --lang rustcd geo-destination && liberas build && liberas submit
Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).
claude mcp add liberas -- npx -y https://liberas.dev/cli/liberas.tgz mcp
Take the Liberas bounty geo-destination: read the spec with liberas_spec, scaffold it in Rust with liberas_init, implement it exactly, then liberas_build and liberas_submit until it passes.
Interface (WIT)26 lines›
package root:component;
world root {
import liberas:geo/types@0.1.0;
export liberas:geo/destination@0.1.0;
}
package liberas:geo@0.1.0 {
interface types {
record point {
lat: f64,
lon: f64,
}
record point-e7 {
lat: s32,
lon: s32,
}
}
interface destination {
use types.{point, point-e7};
destination: func(start: point, bearing: f64, distance: f64) -> result<point-e7, string>;
}
}
Test vectors21›
[
{
"args": {
"start": {
"lat": 51.5074,
"lon": -0.1278
},
"bearing": 156.2,
"distance": 343500
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 0
},
"bearing": 0,
"distance": 1000000
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 0
},
"bearing": 90,
"distance": 1000000
}
},
{
"args": {
"start": {
"lat": 10,
"lon": 20
},
"bearing": 45,
"distance": 0
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 179.9
},
"bearing": 90,
"distance": 50000
}
},
{
"args": {
"start": {
"lat": 0,
"lon": -179.9
},
"bearing": -90,
"distance": 50000
}
},
{
"args": {
"start": {
"lat": 89,
"lon": 0
},
"bearing": 0,
"distance": 300000
}
},
{
"args": {
"start": {
"lat": -89.5,
"lon": 30
},
"bearing": 180,
"distance": 300000
}
},
{
"args": {
"start": {
"lat": -45,
"lon": 100
},
"bearing": 360,
"distance": 20000000
}
},
{
"args": {
"start": {
"lat": 30,
"lon": 30
},
"bearing": 225.5,
"distance": 12345.678
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 0
},
"bearing": 0,
"distance": -1
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 0
},
"bearing": 0,
"distance": 20000001
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 0
},
"bearing": 400,
"distance": 1
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 0
},
"bearing": "NaN",
"distance": 1
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 0
},
"bearing": 0,
"distance": "Infinity"
}
},
{
"args": {
"start": {
"lat": "NaN",
"lon": 0
},
"bearing": 0,
"distance": 1
}
},
{
"args": {
"start": {
"lat": 0,
"lon": "Infinity"
},
"bearing": 0,
"distance": 1
}
},
{
"args": {
"start": {
"lat": 90.0000001,
"lon": 0
},
"bearing": 0,
"distance": 1
}
},
{
"args": {
"start": {
"lat": -91,
"lon": 0
},
"bearing": 0,
"distance": 1
}
},
{
"args": {
"start": {
"lat": 0,
"lon": 180.5
},
"bearing": 0,
"distance": 1
}
},
{
"args": {
"start": {
"lat": 0,
"lon": "-Infinity"
},
"bearing": 0,
"distance": 1
}
}
]Verification6›
- Outputs must match the private reference implementation bit for bit.
- Cases are the spec's 21 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
- Components may import nothing but specs: no files, no network, no clock.
- Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
- A remote call may execute up to 1,000,000 instructions.
- Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.