Skip to content

Instantly share code, notes, and snippets.

@edofic
Created December 11, 2012 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edofic/4258985 to your computer and use it in GitHub Desktop.
Save edofic/4258985 to your computer and use it in GitHub Desktop.
coordinates transformer
class Point{
final double x,y;
Point(a,b){
x=a;
y=b;
}
.......
//transformx lat,lon to unit circle with hard limit
Point[] transform(Point[] points, Point center, double maxMeters){
final int n = points.length;
double maxLog = Math.log(maxMeters);
Point[] q = new Point[n];
for(int i=0; i<n; i++){
double x = (points[i].x - center.x) * 111319; //to distance in meters
double y = (points[i].y - center.y) * 111319;
double r = Math.hypot(x,y);
double phi = Math.atan(y/x);
if(r>maxMeters) r = maxMeters;
r = Math.log(r+1)
r /= maxLog;
x = r*Math.cos(phi);
y = r*Math.sin(phi);
q[i] = new Point(x,y);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment