前言:经度变化1度,111320米.纬度变化1度,111130米
#define pi 3.14159265
double convertArc(double angle)
{
double angle_arc=(angle/180.0)*pi;
return angle_arc;
}
typedef struct{
double lng;
double lat;
double height;
}polygon_points;
QVector<polygon_points> caculateCircle(double lng, double lat, double r, int divide_num)
{
QVector<polygon_points>all_points;
double angle=360/divide_num;
double angle_arc=convertArc(angle);
double var_lng=r/111320;
double var_lat=r/111130;
// 前言:经度变化1度,111320米.纬度变化1度,111130米
for(int i=0;i<divide_num;i++)
{
polygon_points a;
a.lng=lng+qCos(angle_arc*i)*var_lng;
a.lat=lat+qSin(angle_arc*i)*var_lat;
all_points.append(a);
}
return all_points;
}
亲测有效: