PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_vector_angle()

static void test_vector_angle ( void  )
static

Definition at line 1465 of file cu_geodetic.c.

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

Referenced by geodetic_suite_setup().

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