Main Object error

Use Math::PI; please use Google more often.

BTW, I hope you understand sin('#{lat}') is also wrong because of multiple reasons - but if you don't, I should leave it to you to figure out.