PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_lw_arc_length()

static void test_lw_arc_length ( void  )
static

Definition at line 983 of file cu_measures.c.

984 {
985 /* double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3) */
986 
987  POINT2D A1, A2, A3;
988  double d;
989 
990  /* Unit semicircle at 0,0 */
991  A1.x = -1; A1.y = 0;
992  A2.x = 0 ; A2.y = 1;
993  A3.x = 1 ; A3.y = 0;
994 
995  /* Arc above the unit semicircle */
996  d = lw_arc_length(&A1, &A2, &A3);
997  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
998  d = lw_arc_length(&A3, &A2, &A1);
999  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1000 
1001  /* Unit semicircle at 0,0 */
1002  A1.x = 0; A1.y = 1;
1003  A2.x = 1; A2.y = 0;
1004  A3.x = 0; A3.y = -1;
1005 
1006  /* Arc to right of the unit semicircle */
1007  d = lw_arc_length(&A1, &A2, &A3);
1008  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1009  d = lw_arc_length(&A3, &A2, &A1);
1010  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1011 
1012  /* Unit 3/4 circle at 0,0 */
1013  A1.x = -1; A1.y = 0;
1014  A2.x = 1; A2.y = 0;
1015  A3.x = 0; A3.y = -1;
1016 
1017  /* Arc to right of the unit semicircle */
1018  d = lw_arc_length(&A1, &A2, &A3);
1019  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1020  d = lw_arc_length(&A3, &A2, &A1);
1021  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1022 }
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
Definition: lwalgorithm.c:118
double y
Definition: liblwgeom.h:331
double x
Definition: liblwgeom.h:331

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

Referenced by measures_suite_setup().

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