PostGIS  3.1.6dev-r@@SVN_REVISION@@

◆ test_lw_arc_length()

static void test_lw_arc_length ( void  )
static

Definition at line 1082 of file cu_measures.c.

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