PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ test_vector_angle()

static void test_vector_angle ( void  )
static

Definition at line 1459 of file cu_geodetic.c.

References normalize(), vector_angle(), POINT3D::x, POINT3D::y, and POINT3D::z.

Referenced by geodetic_suite_setup().

1460 {
1461  POINT3D p1, p2;
1462  double angle;
1463 
1464  memset(&p1, 0, sizeof(POINT3D));
1465  memset(&p2, 0, sizeof(POINT3D));
1466 
1467  p1.x = 1.0;
1468  p2.y = 1.0;
1469  angle = vector_angle(&p1, &p2);
1470  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI_2, 0.00001);
1471 
1472  p1.x = p2.y = 0.0;
1473  p1.y = 1.0;
1474  p2.x = 1.0;
1475  angle = vector_angle(&p1, &p2);
1476  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI_2, 0.00001);
1477 
1478  p2.y = p2.x = 1.0;
1479  normalize(&p2);
1480  angle = vector_angle(&p1, &p2);
1481  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI_4, 0.00001);
1482 
1483  p2.x = p2.y = p2.z = 1.0;
1484  normalize(&p2);
1485  angle = vector_angle(&p1, &p2);
1486  CU_ASSERT_DOUBLE_EQUAL(angle, 0.955317, 0.00001);
1487  //printf ("angle = %g\n\n", angle);
1488 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:584
double y
Definition: liblwgeom.h:342
double x
Definition: liblwgeom.h:342
double z
Definition: liblwgeom.h:342
double vector_angle(const POINT3D *v1, const POINT3D *v2)
Angle between two unit vectors.
Definition: lwgeodetic.c:474
Here is the call graph for this function:
Here is the caller graph for this function: