def rad d Float(d) * Math::PI / 180.0 end def deg r Float(r) * 180.0 / Math::PI end R = 6371_000.0 def nps phi 2 * R * Math::tan(0.25 * Math::PI - 0.5 * phi) end def nps_inv r t = Math::atan(0.5 * r / R) Math::PI * 0.5 - 2.0 * t end (1..90).each {|phi| r = nps(rad(phi)) b = deg(nps_inv(r)) printf("%4.1f %10.1f %9.5f\n", phi, r, b) }