Skip to content

Instantly share code, notes, and snippets.

@vbachev
Created March 29, 2013 12:00
Show Gist options
  • Save vbachev/5270428 to your computer and use it in GitHub Desktop.
Save vbachev/5270428 to your computer and use it in GitHub Desktop.
transforming geolocation coordinates to relative units ... dummy template
var loc = [
{ x : 3,
y : 3,
gx : 8,
gy : 8
},
{ x : 6,
y : 6,
gx : 12,
gy : 12
}
],
ratio = {},
base = {};
ratio.x = (loc[0].gx - loc[1].gx) / (loc[0].x - loc[1].x);
ratio.y = (loc[0].gy - loc[1].gy) / (loc[0].y - loc[1].y);
base.x = loc[0].gx - loc[0].x * ratio.x;
base.y = loc[0].gy - loc[0].y * ratio.y;
loc[2] = {
gx : 15,
gy : 15
};
loc[2].x = (loc[2].gx - base.x) / ratio.x;
loc[2].y = (loc[2].gy - base.y) / ratio.y;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment