Add comments

This commit is contained in:
Pitchaya Boonsarngsuk
2018-01-31 16:02:37 +00:00
parent 3f21a875df
commit 7bb1cd755b
2 changed files with 36 additions and 4 deletions

View File

@@ -1,9 +1,20 @@
import {pointOnCircle, takeSampleFrom} from "./helpers";
import {placeNearToNearestNeighbour} from "./interpCommon";
/**
* Perform interpolation where the nearest neighbour is found by brute-force.
* For each point to be interpolated:
* - Phase 1: find a nearest beighbour by comparing high-d distance against
each point already in the graph.
* - Phase 2 and 3 are passed onto placeNearToNearestNeighbour
* @param {list} sampleSet - nodes already plotted on the 2D graph
* @param {list} remainderSet - nodes to be interpolated onto the graph
* @param {function} distanceFn - f(nodex, nodey) that calculate high-dimensional
* distance between 2 nodes
* @param {number} endingIts - for phase 3, how many iterations to refine the
* placement of each interpolated point
*/
export default function(sampleSet, remainderSet, distanceFn) {
// var distance = calculateEuclideanDistance;
// console.log("Brute-force");
let sampleSubset = takeSampleFrom(sampleSet, Math.sqrt(sampleSet.length)).sample;
for (let node of remainderSet) {