Hello can you help to rewrite this C++ code to Delphi? It's Convex Hull. Yet I am working with oldDelphi 7so does this Delphi version even support vectors? Or how to go around vectors? I never used vectors in Delphi till now. I worked mostly with TStringLists or maybe some arrays. The C++ is very high level and yet this algo was taken from a tutorial, modified by another C++ expert (because I use C++98 on my old OS). Any help approciated.

I am working on a free program to help free-time mappers to map some areas which are not present in OpenStreetMap data. This includes taking part of map been already rendered and then analyze selected area and to find polygon edges. After that the Convex Hull should be run to get rid of redundant coordinates.

Code:#include <iostream> #include <stdio.h> #include <stdlib.h> #include <math.h> #include <stdbool.h> #include <set> #include <float.h> // DBL_MAX #include <vector> #include <algorithm> #include <typeinfo> #include <cstdlib> // rand() using namespace std; #include<ctime> // time() struct Point { double x, y; }; bool compare(Point a, Point b) { return a.x < b.x || (a.x == b.x && a.y < b.y); } //Returns positive value if B lies to the left of OA, negative if B lies to the right of OA, 0 if collinear double cross(const Point& O, const Point& A, const Point& B) { return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x); } //Returns a list of points on the convex hull std::vector<Point> convex_hull(std::vector<Point> P) { int n = P.size(), k = 0; std::vector<Point> H(2 * n); std::sort(P.begin(), P.end(), compare); // Build lower hull for (int i = 0; i < n; ++i) { while (k >= 2 && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--; H[k++] = P[i]; } // Build upper hull //i starts from n-2 because n-1 is the point which both hulls will have in common //t=k+1 so that the upper hull has atleast two points to begin with for (int i = n - 2, t = k + 1; i >= 0; i--) { while (k >= t && cross(H[k - 2], H[k - 1], P[i]) <= 0) k--; H[k++] = P[i]; } //the last point of upper hull is same with the fist point of the lower hull H.resize(k - 1); return H; } int main() { std::cout << "Hello World!\n"; std::vector<Point> P_in; std::cout << "Input vector size: " << P_in.size(); srand(time(0)); std::cout << "Input vector points: "; for(int a = 0; a < 35; a++) { for(int b = 0; b < 20; b++) { int x = rand() % 100 +1; int y = rand() % 100 +1; std::cout << x << " " << y; std::cout << '\n'; P_in.push_back({x, y}); } } //std::vector<Point> P_in = { {0,0}, {10,10}, {0,10}, {10,0} }; std::vector<Point> P_out = convex_hull(P_in); std::cout << "Output vector size: " << P_out.size(); std::cout << '\n'; for (int i = 0; i < P_out.size(); i++) { std::cout << P_out[i].x << " " << P_out[i].y; std::cout << '\n'; }// for }// main

## Bookmarks