A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/de/d89/graham__scan__functions_8hpp_source.html below:

TheAlgorithms/C++: geometry/graham_scan_functions.hpp Source File

78Point

nextToTop(std::stack<Point> *S) {

93 return

(p1.x - p2.x) * (p1.x - p2.x) + (p1.

y

- p2.

y

) * (p1.

y

- p2.

y

);

105 int

val = (q.y - p.

y

) * (r.x - q.x) - (q.x - p.x) * (r.

y

- q.y);

110 return

(val > 0) ? 1 : 2;

120int

compare(

const void

*vp1,

const void

*vp2) {

121 auto

*p1 =

static_cast<const Point

*

>

(vp1);

122 auto

*p2 =

static_cast<const Point

*

>

(vp2);

125 int

o = orientation(p0, *p1, *p2);

127 return

(distSq(p0, *p2) >= distSq(p0, *p1)) ? -1 : 1;

130 return

(o == 2) ? -1 : 1;

139

std::vector<Point> convexHull(std::vector<Point> points, uint64_t size) {

141 int

ymin = points[0].y, min = 0;

142 for

(

int

i = 1; i < size; i++) {

146 if

((y < ymin) || (ymin == y && points[i].x < points[min].x)) {

147

ymin = points[i].y, min = i;

152

std::swap(points[0], points[min]);

158

qsort(&points[1], size - 1,

sizeof

(

Point

), compare);

165 for

(

int

i = 1; i < size; i++) {

167 while

(i < size - 1 && orientation(p0, points[i], points[i + 1]) == 0) {

171

points[m] = points[i];

182

std::stack<Point> St;

188 for

(

int

i = 3; i < m; i++) {

192 while

(St.size() > 1 &&

193

orientation(nextToTop(&St), St.top(), points[i]) != 2) {

199

std::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