var h = 640.0;

var points_for_approximation = [[37, 195], [66, 345], [197, 473], [420, 465], [560, 315], [587, 172]];
var points_for_interpolation = [[37, 195], [66, 345], [197, 473], [420, 465], [560, 315], [587, 172]];
var points_for_both = [[37, 195], [66, 345], [197, 473], [420, 465], [560, 315], [587, 172]];


function nearest_i(xy, points) {
	var best_i = 0;
	var best_d = Math.pow((xy[0]-points[0][0]), 2) + Math.pow((xy[1]-points[0][1]), 2);
	for(var i = 1; i < points.length; ++i) {
		const d = Math.