Created
March 29, 2013 12:00
-
-
Save vbachev/5270428 to your computer and use it in GitHub Desktop.
transforming geolocation coordinates to relative units ... dummy template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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