node-trilateration is a JavaScript module designed to solve the 2D trilateration problem, enabling the calculation of a device's position based on its distances to three known beacon locations. Operating at version 1.0.0, this package provides a straightforward implementation of the geometric principles, where three circles (representing beacons with their distances as radii) are used to determine a unique intersection point. The library's core function takes an array of three beacon objects, each with `x`, `y` coordinates and a `distance`, and returns the calculated `x`, `y` position of the device. It focuses on this specific mathematical task without extensive abstractions, making it a concise solution for applications requiring basic 2D positioning from distance measurements. There is no stated release cadence, suggesting a stable, single-purpose utility.
npm install node-trilaterationVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to install `node-trilateration`, define three beacon locations with their respective distances, and use the `calculate` function to determine and log the device's estimated (x, y) coordinates. It showcases the core functionality for 2D positioning.
Ensure your problem space is strictly two-dimensional or use a different library designed for 3D trilateration/multilateration.
Always pass an array with precisely three beacon objects, each containing valid `x`, `y`, and `distance` numeric properties.
Implement robust input validation for beacon positions and distances in your application code. Consider preprocessing beacon data or adding custom checks for geometric validity if precise error handling is critical.
Ensure that all `x`, `y`, and `distance` values within your beacon objects are valid numbers before passing them to the `calculate` function.
Ensure the input to `trilateration.calculate` is an array of exactly three objects, each having `x`, `y`, and `distance` numeric properties.
Use `const trilateration = require('node-trilateration');` then `trilateration.calculate(beacons);` for CommonJS. For ESM, try `import trilateration from 'node-trilateration';` (though compatibility might vary) and then `trilateration.calculate(beacons);`.Declare and initialize the `beacons` array with the three required beacon objects before calling `trilateration.calculate`.
No dependency data recorded yet.