extends Node func latLonToGlobal(latPos, lonPos, height=1737.4, offset:=Vector3(), origin:=Vector3()): height = height + offset.z var lat = float(latPos+offset.x)*PI/180 var w = cos(lat) var y = sin(lat) var lon = float(lonPos+offset.y)*PI/180 var x = sin(lon) var z = cos(lon) return Vector3(x * height * w, y*height, z * height * w)-origin func globalToLatLon(x, y, z, height=1737.4, offset=Vector3()): height = height + offset.z var lon = 0 if z != 0: #and abs(x/z) < 1: lon = atan(x/z)*180/PI var lat = sign(y)*90 if abs(y) < height: lat = asin(y/height)*180/PI #print("x:"+str(x)+" y:"+str(y)+" z:"+str(z))) #print("lat:"+str(lat)+" lon:"+str(lon)) return Vector2(lat, lon)