#include <vector>
{
int sign = 0;
if (p != a && p != b) {
double wp = v1.
x * v2.
y - v1.
y * v2.
x;
if (std::abs(wp) < 1e-8) {
if ((a - p) * (b - p) < 0.0) {
return true;
}
}
if (((sign > 0) && (wp < 0.0)) || ((sign < 0) && (wp > 0.0))) {
return true;
}
sign = (wp > 0.0) ? 1 : -1;
}
}
if (sign == -1) {
std::swap(a, b);
}
return false;
}
{
Style::setDefaultLineWidth(0.5);
Style::setDefaultPenColor(Color::Blue);
Style::setDefaultFillColor(Color::Null);
std::vector<Point> points;
int n = 25;
while (n--) {
points.push_back(
Point(4 * (Tools::boardRand() % 50), 4 * (Tools::boardRand() % 50)));
}
typedef std::pair<Point, Point> Segment;
std::vector<Segment> segments;
for (size_t a = 0; a < points.size(); ++a) {
for (size_t b = a + 1; b < points.size(); ++b) {
segments.push_back(Segment(pa, pb));
}
}
}
Segment segment = segments.front();
std::vector<Point> polyline;
const Point stop = segment.first;
do {
polyline.push_back(segment.first);
for (const Segment & s : segments) {
if (s.first == segment.second) {
segment = s;
break;
}
}
} while (segment.first != stop);
board <<
Polyline(polyline, Path::Closed, Color::Cyan,
Color(
"#a0a0c0"), 0.5);
board <<
Dot(p.x, p.y, Color::Blue, 1.0);
}
}
Declaration of the Board class.
int main(int argc, char *argv[])
Definition arithmetic.cpp:16
Structure representing an RGB triple.
Definition Color.h:43
bool isSeparing(Point &a, Point &b, const std::vector< Point > &points)
isSeparing
Definition hull.cpp:28
Class for EPS, FIG or SVG drawings.
Definition Board.h:61
void saveSVG(const char *filename, PageSize size=PageSize::BoundingBox, double margin=0.0, Unit unit=Unit::Millimeter) const
Definition Board.cpp:765
A line between two points.
Definition Dot.h:42
Struct representing a 2D point.
Definition Point.h:42
double y
Definition Point.h:44
double x
Definition Point.h:43
A polygonal line described by a series of 2D points.
Definition Polyline.h:38