PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ test_lw_arc_length()

static void test_lw_arc_length ( void  )
static

Definition at line 1090 of file cu_measures.c.

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

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: