I’m translating a function from the mystery language below to python, but I don’t know what I’m doing… should this get me the same results? I don’t understand the do/while stuff in the first snippet. MYSTERY CODE: // Substitute the estimate into the iterative calculation that // converges on the correct Latitude value. var part1 = (1 - (Ec * Math.sin(Lat0))) / (1 + (Ec * Math.sin(Lat0))); var LatR = Pi2 - (2 * Math.atan(t * Math.pow(part1,(Ec/2)))); do { Lat0 = LatR; part1 = (1 - (Ec * Math.sin(Lat0))) / (1 + (Ec * Math.sin(Lat0))); //LatR = Pi2 - (2 * Math.atan2((t * (part1**(Ec/2))),1)); LatR = Pi2 - (2 * Math.atan(t * Math.pow(part1,(Ec/2)))); } while (Math.abs(LatR - Lat0) > 0.000000002); MY PYTHON ATTEMPT:part1 = (1 - (Ec * math.sin(Lat0))) / (1 + (Ec * math.sin(Lat0)))
LatR = Pi2 - (2 * math.atan(t * math.pow(part1,(Ec/2)))) while (abs(LatR - Lat0) > 0.000000002): Lat0 = LatR part1 = (1 - (Ec * math.sin(Lat0))) / (1 + (Ec * math.sin(Lat0))) LatR = Pi2 - (2 * math.atan(t * math.pow(part1,(Ec/2))))
Kevin Bell
GIS Specialist
Salt Lake City Transportation Division
349 South 200 East, Suite 450
P.O. Box 145502
Salt Lake City, UT 84114-5502