PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_lw_dist2d_arc_arc ( void  )
static

Definition at line 573 of file cu_measures.c.

References DIST_MIN, DISTPTS::distance, lw_dist2d_arc_arc(), lw_dist2d_distpts_init(), POINT2D::x, and POINT2D::y.

Referenced by measures_suite_setup().

574 {
575  /* lw_dist2d_arc_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3,
576  const POINT2D *B1, const POINT2D *B2, const POINT2D *B3,
577  DISTPTS *dl) */
578  DISTPTS dl;
579  POINT2D A1, A2, A3, B1, B2, B3;
580  int rv;
581 
582  /* Unit semicircle at 0,0 */
583  B1.x = -1; B1.y = 0;
584  B2.x = 0 ; B2.y = 1;
585  B3.x = 1 ; B3.y = 0;
586 
587  /* Arc above the unit semicircle */
589  A1.x = -1; A1.y = 3;
590  A2.x = 0 ; A2.y = 2;
591  A3.x = 1 ; A3.y = 3;
592  rv = lw_dist2d_arc_arc(&A1, &A2, &A3, &B1, &B2, &B3, &dl);
593  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 1, 0.000001);
594 
595  /* Arc grazes the unit semicircle */
597  A1.x = -1; A1.y = 2;
598  A2.x = 0 ; A2.y = 1;
599  A3.x = 1 ; A3.y = 2;
600  rv = lw_dist2d_arc_arc(&A1, &A2, &A3, &B1, &B2, &B3, &dl);
601  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0, 0.000001);
602 
603  /* Circles intersect, but arcs do not */
605  A1.x = -1; A1.y = 1;
606  A2.x = 0; A2.y = 2;
607  A3.x = 1; A3.y = 1;
608  rv = lw_dist2d_arc_arc(&A1, &A2, &A3, &B1, &B2, &B3, &dl);
609  CU_ASSERT_DOUBLE_EQUAL(dl.distance, sqrt(2)-1, 0.000001);
610 
611  /* Circles and arcs intersect */
613  A1.x = -1; A1.y = 1;
614  A2.x = 0; A2.y = 0;
615  A3.x = 1; A3.y = 1;
616  rv = lw_dist2d_arc_arc(&A1, &A2, &A3, &B1, &B2, &B3, &dl);
617  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0, 0.000001);
618 
619  /* inscribed and closest on arcs */
621  A1.x = -0.5; A1.y = 0.0;
622  A2.x = 0.0; A2.y = 0.5;
623  A3.x = 0.5; A3.y = 0.0;
624  rv = lw_dist2d_arc_arc(&A1, &A2, &A3, &B1, &B2, &B3, &dl);
625  //printf("distance %g\n", dl.distance);
626  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
627 
628  /* inscribed and closest not on arcs */
630  A1.x = -0.5; A1.y = 0.0;
631  A2.x = 0.0; A2.y = -0.5;
632  A3.x = 0.5; A3.y = 0.0;
633  rv = lw_dist2d_arc_arc(&A1, &A2, &A3, &B1, &B2, &B3, &dl);
634  //printf("distance %g\n", dl.distance);
635  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
636 }
#define DIST_MIN
int lw_dist2d_arc_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Definition: measures.c:1438
double x
Definition: liblwgeom.h:284
double y
Definition: liblwgeom.h:284
double distance
Definition: measures.h:23
Structure used in distance-calculations.
Definition: measures.h:21
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
Definition: measures.c:27

Here is the call graph for this function:

Here is the caller graph for this function: