Nodejs Degree to Radian Convert toRadians()

Here you can find the source of toRadians()

Method Source Code

function getHaversineDistance(point1, point2){   
   var R = 6372.8;

   var dLat = (point2.lat - point1.lat).toRadians();
     var dLon = (point2.lon - point1.lon).toRadians();
     var lat1 = point1.lat.toRadians();
     var lat2 = point2.lat.toRadians();

   var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2)
   var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a))
   /*from  w  w  w.j  a  v  a 2s . c o  m*/
   return = R * c;    
}

Number.prototype.toRadians = function() {
   return (this.valueOf() * Math.PI) / 180;
}

Related

  1. toRad()
    Number.prototype.toRad = function() {
        return this * Math.PI / 180;
    };
    
  2. toRad()
    Number.prototype.toRad = function() {
      return (this / 180) * Math.PI;
    };
    
  3. toRad() // convert degrees to radians
    Number.prototype.toRad = function() {  
      return this * Math.PI / 180;
    
  4. toRadians()
    Number.prototype.toRadians = function() {
        return (this / 360) * 2 * Math.PI;
    
  5. toRadians()
    Number.prototype.toRadians = function() { 
      return this * Math.PI / 180; 
    
  6. toRadians()
    'use strict'
    Number.prototype.toRadians = function() {
      return this * Math.PI / 180;
    
  7. toRadians()
    Number.prototype.toRadians = function() { 
        return (this.valueOf() * Math.PI) / 180; 
    
  8. toReadableFileSize(bytes)
    function toReadableFileSize(bytes) {
      var i = 0;
      var byteUnits = [' bytes' , ' kB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB'];
      while (bytes > 1024) {
        bytes = bytes / 1024;
        i++;
      if (i > 0)
        return bytes.toFixed(1) + byteUnits[i];
    ...
    
  9. toRoman( ()
    assert = require("assert");
    Number.prototype.toRoman = (function () {
      var nmap = {
        M: 1000, CM: 900, D: 500, CD: 400, C: 100, XC: 90, L: 50, XL: 40, X: 10, IX: 9, V: 5, IV: 4, I: 1
      };
      var toRomanR = function toRomanR(num) {
        for (var a in nmap) {
          if (nmap[a] <= num) {
            return a + toRomanR(num - nmap[a]);
    ...