nextToTop(std::stack<Point> *S) {
93 return(p1.x - p2.x) * (p1.x - p2.x) + (p1.
y- p2.
y) * (p1.
y- p2.
y);
105 intval = (q.y - p.
y) * (r.x - q.x) - (q.x - p.x) * (r.
y- q.y);
110 return(val > 0) ? 1 : 2;
120intcompare(
const void*vp1,
const void*vp2) {
121 auto*p1 =
static_cast<const Point*
>(vp1);
122 auto*p2 =
static_cast<const Point*
>(vp2);
125 into = orientation(p0, *p1, *p2);
127 return(distSq(p0, *p2) >= distSq(p0, *p1)) ? -1 : 1;
130 return(o == 2) ? -1 : 1;
139std::vector<Point> convexHull(std::vector<Point> points, uint64_t size) {
141 intymin = points[0].y, min = 0;
142 for(
inti = 1; i < size; i++) {
146 if((y < ymin) || (ymin == y && points[i].x < points[min].x)) {
147ymin = points[i].y, min = i;
152std::swap(points[0], points[min]);
158qsort(&points[1], size - 1,
sizeof(
Point), compare);
165 for(
inti = 1; i < size; i++) {
167 while(i < size - 1 && orientation(p0, points[i], points[i + 1]) == 0) {
171points[m] = points[i];
182std::stack<Point> St;
188 for(
inti = 3; i < m; i++) {
192 while(St.size() > 1 &&
193orientation(nextToTop(&St), St.top(), points[i]) != 2) {
199std::vector<Point>
result;
201 while(!St.empty()) {
uint64_t result(uint64_t n)
int y
Point respect to x coordinate.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4