{"library":"node-trilateration","title":"Node Trilateration","description":"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.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-trilateration"],"cli":null},"imports":["const trilateration = require('node-trilateration');","const { calculate } = require('node-trilateration');","const trilateration = require('node-trilateration');\nconst pos = trilateration.calculate(beacons);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const trilateration = require('node-trilateration');\n\n// Define three beacons with their coordinates and distances to the device.\n// These distances represent the radii of circles centered at each beacon.\nconst beacons = [\n\t{x: 2, y: 4, distance: 5.7},\n\t{x: 5.5, y: 13, distance: 6.8},\n\t{x: 11.5, y: 2, distance: 6.4}\n];\n\n// Perform the trilateration calculation to find the device's position.\nconst pos = trilateration.calculate(beacons);\n\n// Log the calculated (x, y) coordinates of the device.\nconsole.log(`Calculated device position: X: ${pos.x}; Y: ${pos.y}`);\n// Expected output: Calculated device position: X: 7; Y: 6.5 (approximately)","lang":"javascript","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}