17#define izzi_POINTS_H 1
22using point_2t = std::tuple<space_type, space_type>;
35 std::ostringstream oss;
41using vspace = std::vector<space_type>;
56 const double xscale = 1,
const double yscale = 1)
58 for (
const auto& [x, y] : cpoints)
60 xpoints.push_back(x / xscale);
61 ypoints.push_back(y / yscale);
71 vr.insert(vr.end(), r1.begin(), r1.end());
72 vr.insert(vr.end(), r2.begin(), r2.end());
83 if (!xpoints.empty() && !ypoints.empty())
85 sort(xpoints.begin(), xpoints.end());
86 sort(ypoints.begin(), ypoints.end());
90 const bool padp(
true);
93 const double sigd = pow(10, pown);
95 const double dx = xpoints.back();
96 double ix = std::round(dx * sigd) / sigd;
98 xpoints.push_back(ix);
100 const double dy = ypoints.back();
101 uint iy = std::round(dy * sigd) / sigd;
103 ypoints.push_back(iy);
107 rangemaxx = std::make_tuple(xpoints.back(), ypoints.back());
116 const double xscale = 1,
const double yscale = 1)
130 const double sigd = pow(10, pown);
132 for (
const double& d : points)
137 uint itrunc(dn * sigd);
138 npoints.push_back(itrunc / sigd);
141 npoints.push_back(dn);
150 auto [ x1, y1 ] = p1;
151 auto [ x2, y2 ] = p2;
152 auto distancex = (x2 - x1) * (x2 - x1);
153 auto distancey = (y2 - y1) * (y2 - y1);
154 space_type distance = sqrt(distancex + distancey);
178 Point(
double x = 0,
double y = 0,
const std::string s =
"")
183 {
return std::hypot(
x - other.
x,
y - other.
y); }
187 {
return x == other.
x &&
y == other.
y; }
191 {
return Point(
x + other.
x,
y + other.
y); }
195 {
return Point(
x / scalar,
y / scalar); }
204 :
pt(p.x, p.y, p.name),
weight(w) { }
218 outpoints.reserve(inpoints.size());
221 {
auto [ s,
pt ] = p;
auto [x, y] =
pt;
return Point(x, y, s); };
222 std::ranges::transform(inpoints, std::back_inserter(outpoints), lconv);
230 using std::make_tuple;
232 outpoints.reserve(inpoints.size());
234 auto lconv = [](
const Point& p){
auto pt = make_tuple(p.x, p.y);
return make_tuple(p.name,
pt); };
235 std::ranges::transform(inpoints, std::back_inserter(outpoints), lconv);
std::vector< Point > vpoints
std::vector< WeightedPoint > vwpoints
@ pt
Point where 1 pixel x 1/72 dpi x 96 PPI = .26 mm.
bool detect_collision(const point_2t &p1, const int r1, const point_2t &p2, const int r2)
vspace narrow_vspace(const vspace &points, uint pown)
Truncate double to double with pown signifigant digits.
vrange union_vrange(const vrange &r1, const vrange &r2)
Union two ranges.
std::vector< point_2ts > vrangenamed
std::set< point_2t > srange
Latitude and Longitude Ranges.
std::tuple< ulong, point_2t > point_2tn
Point (x,y) in 2D space with weight n.
const string to_string(const unit e)
double space_type
Base floating point type.
std::vector< point_2tn > vrangen
std::set< point_2tn > srangen
std::vector< vrange > vvranges
std::vector< point_2t > vrange
point_2t max_vrange(vspace &xpoints, vspace &ypoints, const uint pown)
For each dimension of vrnage, find min/max and return (xmax, ymax) NB: Assumes zero is min.
void split_vrange(const vrange &cpoints, vspace &xpoints, vspace &ypoints, const double xscale=1, const double yscale=1)
Decompose/split 2D ranges to 1D spaces, perhaps with scaling.
vpoints vrangenamed_to_points(const vrangenamed &inpoints)
Convert point_2ts to Point.
std::tuple< string, point_2t > point_2ts
Named Point (x,y) in 2D space.
std::vector< space_type > vspace
Split range, so one dimension of (x,y) cartesian plane.
space_type distance_cartesian(const point_2t &p1, const point_2t &p2)
Find cartesian distance between two 2D points.
vrangenamed points_to_vrangenamed(const vpoints &inpoints)
Convert Point to point_2t.
std::tuple< space_type, space_type > point_2t
Point (x,y) in 2D space, space_type defaults to double.
double distance(const Point &other) const
Point operator+(const Point &other) const
bool operator==(const Point &other) const
Point(double x=0, double y=0, const std::string s="")
Point operator/(double scalar) const
WeightedPoint(const Point &p, size_t w)