PostGIS  2.5.1dev-r@@SVN_REVISION@@

◆ test_lw_arc_length()

static void test_lw_arc_length ( void  )
static

Definition at line 920 of file cu_measures.c.

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

Referenced by measures_suite_setup().

921 {
922 /* double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3) */
923 
924  POINT2D A1, A2, A3;
925  double d;
926 
927  /* Unit semicircle at 0,0 */
928  A1.x = -1; A1.y = 0;
929  A2.x = 0 ; A2.y = 1;
930  A3.x = 1 ; A3.y = 0;
931 
932  /* Arc above the unit semicircle */
933  d = lw_arc_length(&A1, &A2, &A3);
934  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
935  d = lw_arc_length(&A3, &A2, &A1);
936  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
937 
938  /* Unit semicircle at 0,0 */
939  A1.x = 0; A1.y = 1;
940  A2.x = 1; A2.y = 0;
941  A3.x = 0; A3.y = -1;
942 
943  /* Arc to right of the unit semicircle */
944  d = lw_arc_length(&A1, &A2, &A3);
945  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
946  d = lw_arc_length(&A3, &A2, &A1);
947  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
948 
949  /* Unit 3/4 circle at 0,0 */
950  A1.x = -1; A1.y = 0;
951  A2.x = 1; A2.y = 0;
952  A3.x = 0; A3.y = -1;
953 
954  /* Arc to right of the unit semicircle */
955  d = lw_arc_length(&A1, &A2, &A3);
956  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
957  d = lw_arc_length(&A3, &A2, &A1);
958  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
959 }
double x
Definition: liblwgeom.h:330
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:330
Here is the call graph for this function:
Here is the caller graph for this function: