vivaldi-coordinates
v1.0.0
Published
Vivaldi: A Decentralized Network Coordinate System
Downloads
6
Maintainers
Readme
vivaldi-coordinates
Vivaldi: A Decentralized Network Coordinate System. Originaly description here.This package based on source code of Vuze and required nodejs >= 4.
API
create(data: Float32Array): VivaldiPosition
Create VivaldiPosition
instance from raw coordinates. Argument data
should have length == 4.
create(data: HeightCoordinates): VivaldiPosition
Create VivaldiPosition
instance from HeightCoordinates
instance.
create([error: Number]): VivaldiPosition
Create new empty VivaldiPosition
instance. Argument error
is optional.
update(rtt: Number, p1: VivaldiPosition, p2: VivaldiPosition|HeightCoordinates): bool
Update position p1
with other position p2
and time rtt
.
distance(p1: VivaldiPosition, p2: VivaldiPosition|HeightCoordinates): number
Calculate distace between p1
and p2
.
equals(p1, p2): bool
Check to equals p1
and p2
.
Example
const vivaldi = require('vivaldi-coordinates');
var local_pos = vivaldi.create(); // create new empty pos;
var remote_pos; // position from some remote host
var rtt = 7; // ping time to remote host
vivaldi.update(rtt, local_pos, remote_pos); // update local position
License
MIT, 2015 (c) Dmitry Tsvettsikh