PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ test_lw_arc_length()

static void test_lw_arc_length ( void  )
static

Definition at line 870 of file cu_measures.c.

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

Referenced by measures_suite_setup().

871 {
872 /* double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3) */
873 
874  POINT2D A1, A2, A3;
875  double d;
876 
877  /* Unit semicircle at 0,0 */
878  A1.x = -1; A1.y = 0;
879  A2.x = 0 ; A2.y = 1;
880  A3.x = 1 ; A3.y = 0;
881 
882  /* Arc above the unit semicircle */
883  d = lw_arc_length(&A1, &A2, &A3);
884  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
885  d = lw_arc_length(&A3, &A2, &A1);
886  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
887 
888  /* Unit semicircle at 0,0 */
889  A1.x = 0; A1.y = 1;
890  A2.x = 1; A2.y = 0;
891  A3.x = 0; A3.y = -1;
892 
893  /* Arc to right of the unit semicircle */
894  d = lw_arc_length(&A1, &A2, &A3);
895  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
896  d = lw_arc_length(&A3, &A2, &A1);
897  CU_ASSERT_DOUBLE_EQUAL(d, M_PI, 0.000001);
898 
899  /* Unit 3/4 circle at 0,0 */
900  A1.x = -1; A1.y = 0;
901  A2.x = 1; A2.y = 0;
902  A3.x = 0; A3.y = -1;
903 
904  /* Arc to right of the unit semicircle */
905  d = lw_arc_length(&A1, &A2, &A3);
906  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
907  d = lw_arc_length(&A3, &A2, &A1);
908  CU_ASSERT_DOUBLE_EQUAL(d, 3*M_PI_2, 0.000001);
909 }
double x
Definition: liblwgeom.h:328
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:328
Here is the call graph for this function:
Here is the caller graph for this function: