#include <cmath>
#include <math.h>

const double Earth_radius = 6378.1;

2倍の距離（double lat1、double lon1、double lat2、double lon2）
{
//緯度と経度を変換します
//ラジアンの球体座標。
double rlat1 = lat1 *（m_pi/180）;
double rlat2 = lat2 *（m_pi/180）;
double rlon1 = lon1 *（m_pi/180）;
double rlon2 = lon2 *（m_pi/180）;

// Haversineフォーミュラ
double dlon = rlon2 -rlon1;
double dlat = rlat2 -rlat1;
double a = pow（sin（dlat / 2）、2） + cos（rlat1） * cos（rlat2） * pow（sin（dlon / 2）、2）;
double c = 2 * atan2（sqrt（a）、sqrt（1 -a））;

//距離を計算します
倍の距離= arew_radius * c;

戻り距離;
}
#include <cmath>
#include <math.h>

const double earth_radius = 6378.1;

double distance(double lat1, double lon1, double lat2, double lon2) 
{ 
	// convert latitude and longitude to 
	// spherical coordinates in radians. 
	double rlat1 = lat1 * (M_PI/180); 
	double rlat2 = lat2 * (M_PI/180); 
	double rlon1 = lon1 * (M_PI/180); 
	double rlon2 = lon2 * (M_PI/180); 
	
	// Haversine formula  
	double dlon = rlon2 - rlon1;  
	double dlat = rlat2 - rlat1; 
	double a = pow(sin(dlat / 2), 2) + cos(rlat1) * cos(rlat2) * pow(sin(dlon / 2), 2); 
	double c = 2 * atan2(sqrt(a), sqrt(1 - a)); 
	
	// calculate the distance 
	double distance = earth_radius * c; 
	
	return distance; 
}