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

Definition at line 442 of file cu_measures.c.

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

Referenced by measures_suite_setup().

443 {
444  /* int lw_dist2d_pt_arc(const POINT2D* P, const POINT2D* A1, const POINT2D* A2, const POINT2D* A3, DISTPTS* dl) */
445  DISTPTS dl;
446  POINT2D P, A1, A2, A3;
447  int rv;
448 
449 
450  /* Point within unit semicircle, 0.5 units from arc */
451  A1.x = -1; A1.y = 0;
452  A2.x = 0 ; A2.y = 1;
453  A3.x = 1 ; A3.y = 0;
454  P.x = 0 ; P.y = 0.5;
455 
457  rv = lw_dist2d_pt_arc(&P, &A1, &A2, &A3, &dl);
458  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
459 
460  /* Point outside unit semicircle, 0.5 units from arc */
461  P.x = 0 ; P.y = 1.5;
463  rv = lw_dist2d_pt_arc(&P, &A1, &A2, &A3, &dl);
464  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
465 
466  /* Point outside unit semicircle, sqrt(2) units from arc end point*/
467  P.x = 0 ; P.y = -1;
469  rv = lw_dist2d_pt_arc(&P, &A1, &A2, &A3, &dl);
470  CU_ASSERT_DOUBLE_EQUAL(dl.distance, sqrt(2.0), 0.000001);
471 
472  /* Point outside unit semicircle, sqrt(2)-1 units from arc end point*/
473  P.x = 1 ; P.y = 1;
475  rv = lw_dist2d_pt_arc(&P, &A1, &A2, &A3, &dl);
476  CU_ASSERT_DOUBLE_EQUAL(dl.distance, sqrt(2.0)-1, 0.000001);
477 
478  /* Point on unit semicircle midpoint */
479  P.x = 0 ; P.y = 1;
481  rv = lw_dist2d_pt_arc(&P, &A1, &A2, &A3, &dl);
482  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0, 0.000001);
483 
484  /* Point on unit semicircle endpoint */
485  P.x = 1 ; P.y = 0;
487  rv = lw_dist2d_pt_arc(&P, &A1, &A2, &A3, &dl);
488  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0, 0.000001);
489 
490  /* Point inside closed circle */
491  P.x = 0 ; P.y = 0.5;
492  A2.x = 1; A2.y = 0;
493  A3 = A1;
495  rv = lw_dist2d_pt_arc(&P, &A1, &A2, &A3, &dl);
496  //printf("distance %g\n", dl.distance);
497  CU_ASSERT_DOUBLE_EQUAL(dl.distance, 0.5, 0.000001);
498 }
#define DIST_MIN
double x
Definition: liblwgeom.h:284
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
Definition: measures.c:1395
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: