Beispiel #1
0
//# from http://www.movable-type.co.uk/scripts/latlong.html
double get_Haversine_distance(double lat1, double lon1, double lat2, double lon2) {
    double dLat, dLon, a, c, d;

    dLat = degree_to_radian(lat2-lat1);
    dLon = degree_to_radian(lon2-lon1);
    a = sin(dLat/2)*sin(dLat/2) + cos(degree_to_radian(lat1))*cos(degree_to_radian(lat2))*sin(dLon/2)*sin(dLon/2);
    c = 2*atan(sqrt(a)/sqrt(1-a));
    d = R * c;

    return d;
}
Beispiel #2
0
void draw_arraw_line_with_angle(double start_x, double start_y, double length, double degree)
{
    double delt_x, delt_y, end_x, end_y, radian;

    radian = degree_to_radian(degree);
    delt_x = length * cos(radian);
    delt_y = length * sin(radian);

    end_x = start_x + delt_x;
    end_y = start_y - delt_y;

    draw_arraw_line(start_x, start_y, end_x, end_y);
}
Beispiel #3
0
double get_Cartesian_distance(double lat1, double lon1, double lat2, double lon2) {
    double lat1r, lon1r, lat2r, lon2r;
    double half_pi;
    double x1, y1, z1, x2, y2, z2;

    // # convert from degree to radian
    lat1r = degree_to_radian(lat1);
    lon1r = degree_to_radian(lon1);
    lat2r = degree_to_radian(lat2);
    lon2r = degree_to_radian(lon2);

    half_pi = pi/2.0;

    x1 = R * sin(half_pi-lat1r) * cos(lon1r);
    y1 = R * sin(half_pi-lat1r) * sin(lon1r);
    z1 = R * cos(half_pi-lat1r);

    x2 = R * sin(half_pi-lat2r) * cos(lon2r);
    y2 = R * sin(half_pi-lat2r) * sin(lon2r);
    z2 = R * cos(half_pi-lat2r);

    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) + (z1-z2)*(z1-z2));
}
Beispiel #4
0
bool extract_ellipsoid_definition( GsTLTriplet& ranges, 
					 GsTLTriplet& angles,
					 const std::string& tag_name,
					 const Parameters_handler* parameters,
					 Error_messages_handler* errors ) {

  std::string params = parameters->value( tag_name );
//  String_Op::replace( params, "\n", " " ); 
  std::vector<double> param_vals = String_Op::to_numbers<double>( params );

  if( param_vals.size() != 6 ) {
    std::string tag = String_Op::split_string( tag_name, "." ).first;
    errors->report( tag, "Specify exactly 3 range values and 3 angles" );
    return false;
  } 

  ranges[0] = param_vals[0];
  ranges[1] = param_vals[1];
  ranges[2] = param_vals[2];
/*
  if( ranges[0] < ranges[1] || ranges[1] < ranges[2] ) {
    std::string tag = String_Op::split_string( tag_name, "." ).first;
    std::ostringstream message;
    message << "The range in the major direction must be greater than "
            << "the ones in the medium and minor directions";
    errors->report( tag, message.str() );
    return false;
  }
*/
  angles[0] = degree_to_radian( param_vals[3] );
  angles[1] = degree_to_radian( param_vals[4] );
  angles[2] = degree_to_radian( param_vals[5] );
  convert_to_math_standard_angles_rad( angles[0], angles[1], angles[2] );

  return true;
}
int main ()
{
    // 異なる型(タグ)間での暗黙変換はできない
    {
        degree<float> deg(90.0f);
//      radian<float> rad = deg; // コンパイルエラー!型が違う
    }

    // degreeからradianへの変換
    {
        degree<float> deg(90.0f);
        radian<float> rad = degree_to_radian(deg);
        std::cout << rad.get() << std::endl;
    }

    // radianからdegreeへの変換
    {
        radian<float> rad(0.5 * boost::math::constants::pi<float>());
        degree<float> deg = radian_to_degree(rad);
        std::cout << deg.get() << std::endl;
    }
}
Beispiel #6
0
static void draw_arraw_line(double  s_x, double  s_y, double  e_x, double  e_y)
{
    draw_line((int)s_x, (int)s_y, (int)e_x, (int)e_y, RGB(0, 0, 0xff));
    draw_arraw_line_imp((int)s_x, (int)s_y, (int)e_x, (int)e_y, 15, degree_to_radian(60));
}