16__extension__
using i128 = __int128;
19 std::vector<Point>
pts;
35 return static_cast<i128>(b.
x - a.
x) * (c.
y - a.
y) -
static_cast<i128>(b.
y - a.
y) * (c.
x - a.
x);
bool segments_intersect(Point a, Point b, Point c, Point d)
True if closed segments ab and cd share at least one point.
__int128 i128
GCC extension; exact products of nm coordinates.
bool seg_seg_closer(Point a, Point b, Point c, Point d, Coord t)
True if the distance between segments ab and cd is strictly less than t (t >= 0).
std::vector< Point > circle_points(Point centre, Coord radius, Coord max_error=5 '000)
Circle outline as a closed polyline (first point repeated at the end).
long double point_seg_dist(Point p, Point a, Point b)
Distances in nm (not squared), for reporting (long double).
double gap(const Shape &a, const Shape &b)
Gap between two shapes in nm (negative = overlap depth bound; 0 when cores touch with r = 0).
std::vector< Point > arc_points(Point start, Point mid, Point end, Coord max_error=5 '000)
Flattens a circular arc through start/mid/end into points with sagitta error <= max_error.
i128 orient(Point a, Point b, Point c)
Orientation of c relative to a→b: >0 left (counter-clockwise in y-up math terms), <0 right,...
bool closer_than_disk(const Shape &a, Point c, Coord r, Coord clearance)
Equivalent to closer_than(a, Shape::point(c, r), clearance), without allocating.
bool point_seg_closer(Point p, Point a, Point b, Coord t)
True if the distance from p to segment ab is strictly less than t (t >= 0).
bool point_in_polygon(Point p, const std::vector< Point > &poly)
Point in closed polygon (boundary counts as inside).
bool closer_than(const Shape &a, const Shape &b, Coord clearance)
True if the gap between the two shapes (distance between their surfaces, negative when they overlap) ...
long double seg_seg_dist(Point a, Point b, Point c, Point d)
std::vector< Point > convex_hull(std::vector< Point > pts)
Convex hull, counter-clockwise in a y-up frame, no repeated point (Andrew's monotone chain,...
std::int64_t Coord
Engine coordinate: signed 64-bit nanometres.
Integer-nanometre points and KiCad-compatible rotation.
static Shape polyline(std::vector< Point > pts, Coord r)
static Shape polygon(std::vector< Point > pts, Coord r=0)
Box box
bounding box including r
void set_point(Point p, Coord r)
Reset to a disk, reusing point storage for scratch legality checks.
std::vector< Point > pts
1 point, open polyline (>= 2), or closed polygon (>= 3)
bool closed
polygon interior is part of the shape
static Shape point(Point p, Coord r)
static Shape segment(Point a, Point b, Coord r)