Skip to content

Instantly share code, notes, and snippets.

@jbum
Created September 28, 2017 17:19
Show Gist options
  • Save jbum/0f60768ef29b46246b1d5906003a47cf to your computer and use it in GitHub Desktop.
Save jbum/0f60768ef29b46246b1d5906003a47cf to your computer and use it in GitHub Desktop.
def pointPhysics():
global pts # array of points on a sphere, specified as (lat,lon) pairs
new_pts = []
for i in xrange(nbrPoints):
(clat,clon) = pts[i] # center point for gnomonic projection (projects to 0,0)
fx,fy = (0,0)
for j in xrange(nbrPoints):
if j == i:
continue
jlat,jlon = pts[j]
hd = haversine(pts[i],pts[j])
if hd < maxInfluence:
force = map(pow(hd/maxInfluence,2),0,1,1,0) * iScale # closer points have more influence..
gx,gy = gnomic(jlat,jlon,clat,clon)
d = sqrt(gx**2 + gy**2) # dist(0,0,gx,gy)
nfx,nfy = -(gx/d)*force,-(gy/d)*force
fx += nfx
fy += nfy
new_pts.append( ignomic(fx,fy,clat,clon) )
pts = new_pts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment