From a615ef199d40d1eec6b5157dae5d4572695ea7ed Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk <2285135b@student.gla.ac.uk> Date: Tue, 16 Jan 2018 20:14:32 +0000 Subject: [PATCH] Interp fix math --- src/interpolation.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/interpolation.js b/src/interpolation.js index 43df2d0..a4e13a1 100644 --- a/src/interpolation.js +++ b/src/interpolation.js @@ -78,8 +78,8 @@ function placeNearToNearestNeighbour(node, minNode, sample, sampleCache, radius) } } - var angle = binarySearch(lowBound, highBound, minNode.x, minNode.y, radius, node, sample, sampleCache); - var newPoint = centerPoint(angle, radius, minNode.x, minNode.y); + let angle = binarySearch(lowBound, highBound, minNode.x, minNode.y, radius, node, sample, realDistances); + let newPoint = centerPoint(angle, radius, minNode.x, minNode.y); // console.log(newPoint); node.x = newPoint.x; @@ -94,10 +94,11 @@ function placeNearToNearestNeighbour(node, minNode, sample, sampleCache, radius) } - -function centerPoint(angle, radius, posX, posY) { - var x = posX + Math.cos(toRadians(angle) * radius); - var y = posY + Math.sin(toRadians(angle) * radius); +// With a circle radius r, and center at (h,k), +// Find the coordinate of a point at angle degree +function pointOnCircle(h, k, angle, r) { + let x = h + r*Math.cos(toRadians(angle)); + let y = k + r*Math.sin(toRadians(angle)); return { x: x,