1681{
1684 uint32_t ai = 0, bi = 0;
1686 double radius_A, radius_B, d;
1687 int is_disjoint, is_overlapping, is_contained, is_same_center;
1689
1691 lwerror(
"lw_dist2d_arc_arc only supports mindistance");
1692
1693
1700
1701
1704
1705
1706 if (radius_A < 0 && radius_B < 0)
1708
1709
1710 if (radius_A < 0)
1712
1713
1714 if (radius_B < 0)
1716
1717
1719 is_disjoint = (d > (radius_A + radius_B));
1720 is_contained = (d < fabs(radius_A - radius_B));
1721 is_same_center =
p2d_same(¢er_A, ¢er_B);
1722 is_overlapping = ! (is_disjoint || is_contained || is_same_center);
1723
1724
1725
1726
1727
1728
1729 pts_A[ai++] = *A1;
1730 pts_A[ai++] = *A3;
1731 pts_B[bi++] = *B1;
1732 pts_B[bi++] = *B3;
1733
1734
1735
1736
1737
1738
1739 if (is_overlapping)
1740 {
1741
1742
1743
1745 ¢er_A, radius_A,
1746 ¢er_B, radius_B,
1747 intersectionPts);
1748 for (uint32_t i = 0; i < npoints; i++)
1749 {
1750
1751
1752
1753
1754
1757 {
1760 }
1761 }
1762 }
1763
1764
1765
1766
1767
1768
1769
1770 if (is_disjoint || is_contained || is_overlapping)
1771 {
1772 if (!is_same_center)
1773 {
1774
1776 A1, A2, A3,
1777 ¢er_A, radius_A, ¢er_B,
1778 pts_A, &ai);
1779
1780
1782 B1, B2, B3,
1783 ¢er_B, radius_B, ¢er_A,
1784 pts_B, &bi);
1785 }
1786
1787
1789 A1, A2, A3,
1790 ¢er_A, radius_A, B1,
1791 pts_A, &ai);
1792
1793
1795 A1, A2, A3,
1796 ¢er_A, radius_A, B3,
1797 pts_A, &ai);
1798
1799
1801 B1, B2, B3,
1802 ¢er_B, radius_B, A1,
1803 pts_B, &bi);
1804
1805
1807 B1, B2, B3,
1808 ¢er_B, radius_B, A3,
1809 pts_B, &bi);
1810 }
1811
1812
1813
1814
1815
1816 for (uint32_t i = 0; i < ai; i++)
1817 for (uint32_t j = 0; j < bi; j++)
1819
1821}
#define LW_TRUE
Return types for functions with status returns.
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
int lw_arc_is_pt(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if arc A is actually a point (all vertices are the same) .
int lw_pt_in_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if P is on the same side of the plane partition defined by A1/A3 as A2 is.
int p2d_same(const POINT2D *p1, const POINT2D *p2)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static uint32_t lw_dist2d_circle_circle_intersections(const POINT2D *cA, double rA, const POINT2D *cB, double rB, POINT2D *I)
Calculates the intersection points of two overlapping circles.
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
static void lw_dist2d_distpts_set(DISTPTS *dl, double distance, const POINT2D *p1, const POINT2D *p2)
int lw_dist2d_seg_seg(const POINT2D *A, const POINT2D *B, const POINT2D *C, const POINT2D *D, DISTPTS *dl)
Finds the shortest distance between two segments.
int lw_dist2d_seg_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Calculate the shortest distance between an arc and an edge.
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...
static int lw_dist2d_circle_intersections(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *center_A, double radius_A, const POINT2D *P, POINT2D *I, uint32_t *ni)
Calculates the intersection points of a circle and line.