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

Definition at line 639 of file cu_measures.c.

References lw_arc_length(), POINT2D::x, and POINT2D::y.

Referenced by measures_suite_setup().

640 {
641 /* double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3) */
642 
643  POINT2D A1, A2, A3;
644  double d;
645 
646  /* Unit semicircle at 0,0 */
647  A1.x = -1; A1.y = 0;
648  A2.x = 0 ; A2.y = 1;
649  A3.x = 1 ; A3.y = 0;
650 
651  /* Arc above the unit semicircle */
652  d = lw_arc_length(&A1, &A2, &A3);
653  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
654  d = lw_arc_length(&A3, &A2, &A1);
655  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
656 
657  /* Unit semicircle at 0,0 */
658  A1.x = 0; A1.y = 1;
659  A2.x = 1; A2.y = 0;
660  A3.x = 0; A3.y = -1;
661 
662  /* Arc to right of the unit semicircle */
663  d = lw_arc_length(&A1, &A2, &A3);
664  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
665  d = lw_arc_length(&A3, &A2, &A1);
666  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
667 
668  /* Unit 3/4 circle at 0,0 */
669  A1.x = -1; A1.y = 0;
670  A2.x = 1; A2.y = 0;
671  A3.x = 0; A3.y = -1;
672 
673  /* Arc to right of the unit semicircle */
674  d = lw_arc_length(&A1, &A2, &A3);
675  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI/2, 0.000001);
676  d = lw_arc_length(&A3, &A2, &A1);
677  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI/2, 0.000001);
678 }
double x
Definition: liblwgeom.h:284
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
Definition: lwalgorithm.c:119
double y
Definition: liblwgeom.h:284

Here is the call graph for this function:

Here is the caller graph for this function: