Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert degree to radians in ruby

Tags:

ruby

I have a latitude and longitude in degrees and I want to convert these into radians. How can I do that?

P.S. I am using sphinx search engine and it requires values in radians

like image 983
Mohit Jain Avatar asked Jun 13 '11 07:06

Mohit Jain


2 Answers

Just the same way you convert degrees to radians in real life:

radians = degrees * Math::PI / 180 
like image 162
Yuri Stuken Avatar answered Nov 06 '22 13:11

Yuri Stuken


There are 360 degrees and 2 pi radians in a circle. So to convert degrees to radians, divide by 360 and multiply by 2 * pi (approx. 6.28).

Or equivalently, divide by 180 and multiply by pi.

like image 28
Tom Avatar answered Nov 06 '22 14:11

Tom