PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_vector_angle()

static void test_vector_angle ( void  )
static

Definition at line 1482 of file cu_geodetic.c.

1483 {
1484  POINT3D p1, p2;
1485  double angle;
1486 
1487  memset(&p1, 0, sizeof(POINT3D));
1488  memset(&p2, 0, sizeof(POINT3D));
1489 
1490  p1.x = 1.0;
1491  p2.y = 1.0;
1492  angle = vector_angle(&p1, &p2);
1493  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI_2, 0.00001);
1494 
1495  p1.x = p2.y = 0.0;
1496  p1.y = 1.0;
1497  p2.x = 1.0;
1498  angle = vector_angle(&p1, &p2);
1499  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI_2, 0.00001);
1500 
1501  p2.y = p2.x = 1.0;
1502  normalize(&p2);
1503  angle = vector_angle(&p1, &p2);
1504  CU_ASSERT_DOUBLE_EQUAL(angle, M_PI_4, 0.00001);
1505 
1506  p2.x = p2.y = p2.z = 1.0;
1507  normalize(&p2);
1508  angle = vector_angle(&p1, &p2);
1509  CU_ASSERT_DOUBLE_EQUAL(angle, 0.955317, 0.00001);
1510  //printf ("angle = %g\n\n", angle);
1511 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:615
double vector_angle(const POINT3D *v1, const POINT3D *v2)
Angle between two unit vectors.
Definition: lwgeodetic.c:505
double z
Definition: liblwgeom.h:388
double x
Definition: liblwgeom.h:388
double y
Definition: liblwgeom.h:388

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

Referenced by geodetic_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: