76 if (denominator == 0) {
110 if ( ( d1[0] * d2[0] < 0 ) ||
111 ( d1[1] * d2[1] < 0 ) ) {
113 }
else if (
dot(d1,d1) <
dot(d2,d2) ) {
131 if(p00 == p01)
return false;
132 if(p10 == p11)
return false;
148 if(p00 == p01)
return false;
149 if(p10 == p11)
return false;
170 double d0 =
dot(n0,p00);
173 double d1 =
dot(
n1,p10);
194 double d0 =
dot(n0,p00);
197 double d1 =
dot(
n1,p10);
216 double d0 =
dot(n0,p00);
219 double d1 =
dot(
n1,p10);
229 }
else if (A[
X] == B[
X] && A[
Y] < B[
Y]) {
240 unsigned int size = pts.size();
246 if (pts[0] == pts[1]) {
250 std::sort(pts.begin(), pts.end(), &
is_less);
252 if (pts[0] == pts[1]) {
253 pts.erase(pts.begin());
254 }
else if (pts[1] == pts[2]) {
259 if (pts[2] == pts[3]) {
262 if (pts[0] == pts[1]) {
263 pts.erase(pts.begin());
279std::vector<Geom::Point>
283 using namespace Geom;
285 std::vector<Point> results;
296 results.push_back(res);
299 results.push_back(res);
302 results.push_back(res);
305 results.push_back(res);
310 if (results.size() == 2) {
312 Point dir1 (results[1] - results[0]);
313 Point dir2 (p1 - p0);
314 if (
dot(dir1, dir2) < 0) {
315 swap(results[0], results[1]);
332std::optional<LineSegment>
336 std::vector<Point> results;
339 if(results.size() == 2) {
342 return std::optional<LineSegment>();
345std::optional<LineSegment>
367 const unsigned n = p.size();
372 for (
unsigned i = n-1, j = 0; j < n; i = j, j++) {
373 const double ai =
cross(p[j], p[i]);
375 centroid_tmp += (p[j] + p[i])*ai;
379 centroid = centroid_tmp / (3 * atmp);
Various geometrical calculations.
Cartesian point / 2D vector and related operations.
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
CPoint max() const
Get the corner of the rectangle with largest coordinate values.
Infinite line on a plane.
LineSegment segment(Coord f, Coord t) const
Create a segment of this line.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
BezierCurveN< 1 > LineSegment
Line segment.
Various utility functions.
IntersectorKind line_intersection(Geom::Point const &n0, double const d0, Geom::Point const &n1, double const d1, Geom::Point &result)
Finds the intersection of the two (infinite) lines defined by the points p such that dot(n0,...
static void eliminate_duplicates_p(std::vector< Point > &pts)
int centroid(std::vector< Geom::Point > const &p, Geom::Point ¢roid, double &area)
polyCentroid: Calculates the centroid (xCentroid, yCentroid) and area of a polygon,...
static double area(Geom::Point a, Geom::Point b, Geom::Point c)
std::optional< Geom::LineSegment > rect_line_intersect(Geom::Rect &r, Geom::LineSegment ls)
Determine whether & where an (infinite) line intersects a rectangle.
bool line_segment_intersectp(Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11)
Determine whether the line segment from p00 to p01 intersects the infinite line passing through p10 a...
IntersectorKind line_twopoint_intersect(Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11, Geom::Point &result)
Determine whether & where two line segments intersect.
bool segment_intersectp(Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11)
Determine whether two line segments intersect.
Piecewise< SBasis > cross(Piecewise< D2< SBasis > > const &a, Piecewise< D2< SBasis > > const &b)
static bool is_less(Point const &A, Point const &B)
int intersector_ccw(const Geom::Point &p0, const Geom::Point &p1, const Geom::Point &p2)
IntersectorKind line_segment_intersect(Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11, Geom::Point &result)
Determine whether & where a line segments intersects an (infinite) line.
T dot(D2< T > const &a, D2< T > const &b)
IntersectorKind segment_intersect(Geom::Point const &p00, Geom::Point const &p01, Geom::Point const &p10, Geom::Point const &p11, Geom::Point &result)
Determine whether & where two line segments intersect.
D2< T > rot90(D2< T > const &a)