PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_lw_arc_length()

static void test_lw_arc_length ( void  )
static

Definition at line 1075 of file cu_measures.c.

1076 {
1077 /* double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3) */
1078 
1079  POINT2D A1, A2, A3;
1080  double d;
1081 
1082  /* Unit semicircle at 0,0 */
1083  A1.x = -1; A1.y = 0;
1084  A2.x = 0 ; A2.y = 1;
1085  A3.x = 1 ; A3.y = 0;
1086 
1087  /* Arc above the unit semicircle */
1088  d = lw_arc_length(&A1, &A2, &A3);
1089  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1090  d = lw_arc_length(&A3, &A2, &A1);
1091  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1092 
1093  /* Unit semicircle at 0,0 */
1094  A1.x = 0; A1.y = 1;
1095  A2.x = 1; A2.y = 0;
1096  A3.x = 0; A3.y = -1;
1097 
1098  /* Arc to right of the unit semicircle */
1099  d = lw_arc_length(&A1, &A2, &A3);
1100  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1101  d = lw_arc_length(&A3, &A2, &A1);
1102  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
1103 
1104  /* Unit 3/4 circle at 0,0 */
1105  A1.x = -1; A1.y = 0;
1106  A2.x = 1; A2.y = 0;
1107  A3.x = 0; A3.y = -1;
1108 
1109  /* Arc to right of the unit semicircle */
1110  d = lw_arc_length(&A1, &A2, &A3);
1111  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1112  d = lw_arc_length(&A3, &A2, &A1);
1113  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
1114 }
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:376
double x
Definition: liblwgeom.h:376

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: