3D trilateration
Simple computation of trilateration using matlab's Levenberg Marquardt curve-fitting algorithm. Using to locate objects in a 3D coordinate system by at least 4 known points and approximate radii around these fixed points.
Installation
$ npm i lm-trilateration3d
Usage
// import libraryconst trilat = ; // 3D// At least 4 beacons position and distance to locate 3D, if have only 3 beacons, z can not calculate then replace by undefinedvar input3D = data: // X Y Z R 0 0 0 884 884 457 1259 884 0 -884 884 884 1072 -896 884 884; var output3D = trilat;/* { x: [ 5.2 ], y: [ -1.2 ], z: [ 7.7 ]} */ // 2D// At least 3 beacons position and distance to locate 3Dvar input2D = data: // X Y R 00 00 100 100 100 100 100 00 14142135; var output2D = trilat;/* { x: [ 2.205170988086251e-7 ], y: [ 9.999999779478834 ]} */