PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_vector_angle ( void  )
static

Definition at line 1387 of file cu_geodetic.c.

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

Referenced by geodetic_suite_setup().

1388 {
1389  POINT3D p1, p2;
1390  double angle;
1391 
1392  memset(&p1, 0, sizeof(POINT3D));
1393  memset(&p2, 0, sizeof(POINT3D));
1394 
1395  p1.x = 1.0;
1396  p2.y = 1.0;
1397  angle = vector_angle(&p1, &p2);
1398  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI/2, 0.00001);
1399 
1400  p1.x = p2.y = 0.0;
1401  p1.y = 1.0;
1402  p2.x = 1.0;
1403  angle = vector_angle(&p1, &p2);
1404  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI/2, 0.00001);
1405 
1406  p2.y = p2.x = 1.0;
1407  normalize(&p2);
1408  angle = vector_angle(&p1, &p2);
1409  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI/4, 0.00001);
1410 
1411  p2.x = p2.y = p2.z = 1.0;
1412  normalize(&p2);
1413  angle = vector_angle(&p1, &p2);
1414  CU_ASSERT_DOUBLE_EQUAL(angle, 0.955317, 0.00001);
1415  //printf ("angle = %g\n\n", angle);
1416 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:564
double y
Definition: liblwgeom.h:296
double x
Definition: liblwgeom.h:296
double z
Definition: liblwgeom.h:296
double vector_angle(const POINT3D *v1, const POINT3D *v2)
Angle between two unit vectors.
Definition: lwgeodetic.c:454

Here is the call graph for this function:

Here is the caller graph for this function: