Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert kilometers to radians

I need to convert kilometers to radians. Is this correct formula? I need radians for nearsphere in MongoDB.

If I need to convert 5 kilometers to radians I do this:

5/6371

And I get this result (does it seem correct):

0.000784806153

UPDATE

This is not a math issue, I really need to know if I am doing the correct calculations from kilometers to radians to be able to do geospatial queries with MongoDB.

like image 237
Jonathan Clark Avatar asked Aug 29 '12 14:08

Jonathan Clark


People also ask

How do you find the distance in radians?

Radians measure angles by distance traveled. or angle in radians (theta) is arc length (s) divided by radius (r). A circle has 360 degrees or 2pi radians — going all the way around is 2 * pi * r / r. So a radian is about 360 /(2 * pi) or 57.3 degrees.

How do you convert nautical miles to radians?

nm = rad2nm( rad ) converts distances from radians to nautical miles, as measured along a great circle on a sphere with a radius of 3440.065 nm, the mean radius of the Earth.

How do you convert radians to distance?

radians to distance: multiply the radian measure by the radius of the sphere (e.g. the Earth) in the units system that you want to convert the distance to. for Example: if you want to convert 5 miles in radians, then we need to divide the distance (5 miles) by the radius of the sphere (also in miles), which is 3959. then 5/3959 is 0.0012629451...

How many radians does 1000 km span on the Earth?

Convert Kilometers to Radians. How many radians does 1,000 km span on the Earth and on the Moon? rad = km2rad (1000) rad = 0.1570. rad = km2rad (1000, 'moon') rad = 0.5754.

What is the difference between RAD and km2rad?

rad = km2rad (km,radius) converts distances from kilometers to radians, as measured along a great circle on a sphere having the specified radius. rad = km2rad (km,sphere) converts distances from kilometers to radians, as measured along a great circle on a sphere approximating an object in the Solar System.

How much is 1 radian in degrees?

The radian is an SI derived unit of angle, commonly used in maths and engineering. A radian measures approx. 56.296 degrees (when the arc length is equal to the radius). Definition: The angle made by taking the radius of a circle and wrapping it along the circle's edge. Therefore 1 Radian is equal to (180/π) degrees.


3 Answers

Kilometers to radians or distance and radian conversion

I arrived here, was confused, then I watched some Khan academy videos and it made more sense at that point and then I was able to actually look at equations from other sources to further educate myself.

Here's my train of thought.

  1. I see a diagram about radians and I first think radius from a geolocation point which is wrong.

  2. Instead, imagine the earth cut perfectly in half and just focus on one of the halves.

enter image description here

  1. Now face that half toward you and look at the math diagram.

enter image description here

  1. Think of the math diagram as showing from the center of the earth measuring the edge of the earth based on the arc length, after all the earth is curved so any measurement will be curved on the surface of the earth.
  2. Radians are like degrees in a circle and the arc length is literally the distance between A and B in the math diagram.
  3. To you, its a straight line on a bird's eye view, but really it's just a curve in 3d space along the edge of the earth.
  4. Eureka! A lightbulb went on in my head.

distance = earth radius * radians

Thus with some very easy algebra...

radians = distance / earth radius

km radians = distance in km / 6371

mi radians = distance in mi / 3959

Sometimes thinking it through is fun.

Double-check this... https://www.translatorscafe.com/unit-converter/en/length/7-89/kilometer-Earth%E2%80%99s%20equatorial%20radius/

Now in regards to Mongo v3.2 specifically using mongoose in node.js

Despite my best efforts, mongo would not behave correctly as documented for a $geoNear query on a 2d index. never worked

  let aggregate = [
    {
      $geoNear: {
        near: { type: 'Point', coordinates: lonLatArray },
        spherical: false,
        distanceField: 'dist.calculated',
        includeLocs: 'dist.location',
        maxDistance: distanceInMeters / (6371 * 1000),
        query: {
          mode: 'nearme',
          fcmToken: { $exists: true }
        }
      }
    },
    { $skip: skip },
    { $limit: LIMIT }
  ];

However, when I changed to a 2dsphere index, it worked perfectly.

  let aggregate = [
    {
      $geoNear: {
        near: { type: 'Point', coordinates: lonLatArray },
        spherical: true,
        distanceField: 'dist.calculated',
        includeLocs: 'dist.location',
        maxDistance: distanceInMeters,
        query: {
          mode: 'nearme',
          fcmToken: { $exists: true }
        }
      }
    },
    { $skip: skip },
    { $limit: LIMIT }
  ];

But education never seems like a waste of time.

like image 70
King Friday Avatar answered Oct 19 '22 13:10

King Friday


You are correct. In spherical geometry you divide the distance with the radius of the sphere. Mind that you should keep the units. So if you calculate the sphere radius in kilometers then you should use distance in kilometer. If you use miles then you should use Earth radius in miles (approx: 3,963.2).

like image 3
Sagi Forbes Avatar answered Oct 19 '22 12:10

Sagi Forbes


The equatorial radius of the Earth is approximately 3,963.2 miles or 6,378.1 kilometers.

Note : 1 KM = 0.621371 Mile

Here is some simple formulas for calculation :

100 KM to Miles : (100 * 0.621371)

100 KM to radiant : 100 / 6378.1

100 Miles to radiant : 100 / 3963.2

So if you have data in Kilometers then you must use (100 / 6378.1) and for Miles data you can use (100 / 3963.2)

like image 3
Irshad Khan Avatar answered Oct 19 '22 11:10

Irshad Khan