科普:前向交会是通过观测角A和角B求出点P坐标的定位方法。
#举例:
这里默认使用逆时针坐标系,所以sign=1;
已知条件如图所示,求P1,P2坐标。
代码:
#include <stdio.h>
#include <math.h>
typedef struct
{
double x;
double y;
double z;
}point_info_t;
/*
** describe:
** Calculate the coordinates of point P from coordinates A and B
** The coordinates A, B and P are counter clockwise
** param:
** ag_a: angle of PAB
** ag_b: angle of PBA
** grid_a: A point coordinates
** grid_b: B point coordinates
**
** return:
** P point coordinates
*/
#define PI 3.1415926535898
static inline double rad(double rd)
{
return rd * 180 / PI;
}
extern void sincos(double d, double* s, double* c);
static point_info_t test_get_grid(double ag_a, double ag_b, point_info_t grid_a, point_info_t grid_b)
{
point_info_t p;
double sin_a, cos_a, sin_b, cos_b;
double sin_cos, cos_sin, sin_sin