PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ test_lw_arc_length()

static void test_lw_arc_length ( void  )
static

Definition at line 1083 of file cu_measures.c.

1084 {
1085 /* double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3) */
1086 
1087  POINT2D A1, A2, A3;
1088  double d;
1089 
1090  /* Unit semicircle at 0,0 */
1091  A1.x = -1; A1.y = 0;
1092  A2.x = 0 ; A2.y = 1;
1093  A3.x = 1 ; A3.y = 0;
1094 
1095  /* Arc above the unit semicircle */
1096  d = lw_arc_length(&A1, &A2, &A3);
1097  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1098  d = lw_arc_length(&A3, &A2, &A1);
1099  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1100 
1101  /* Unit semicircle at 0,0 */
1102  A1.x = 0; A1.y = 1;
1103  A2.x = 1; A2.y = 0;
1104  A3.x = 0; A3.y = -1;
1105 
1106  /* Arc to right of the unit semicircle */
1107  d = lw_arc_length(&A1, &A2, &A3);
1108  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1109  d = lw_arc_length(&A3, &A2, &A1);
1110  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1111 
1112  /* Unit 3/4 circle at 0,0 */
1113  A1.x = -1; A1.y = 0;
1114  A2.x = 1; A2.y = 0;
1115  A3.x = 0; A3.y = -1;
1116 
1117  /* Arc to right of the unit semicircle */
1118  d = lw_arc_length(&A1, &A2, &A3);
1119  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1120  d = lw_arc_length(&A3, &A2, &A1);
1121  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1122 }
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
Definition: lwalgorithm.c:116
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390

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: