17#define izzi_POINTS_H 1
22using point_2t = std::tuple<space_type, space_type>;
31using point_3t = std::tuple<space_type, space_type, space_type>;
39 std::ostringstream oss;
49 std::ostringstream oss;
50 oss <<
x <<
',' << y <<
',' << z;
56using vspace = std::vector<space_type>;
71 const double xscale = 1,
const double yscale = 1)
73 for (
const auto& [
x, y] : cpoints)
75 xpoints.push_back(
x / xscale);
76 ypoints.push_back(y / yscale);
86 vr.insert(vr.end(), r1.begin(), r1.end());
87 vr.insert(vr.end(), r2.begin(), r2.end());
98 if (!xpoints.empty() && !ypoints.empty())
100 sort(xpoints.begin(), xpoints.end());
101 sort(ypoints.begin(), ypoints.end());
105 const bool padp(
true);
108 const double sigd = pow(10, pown);
110 const double dx = xpoints.back();
111 double ix = std::round(dx * sigd) / sigd;
113 xpoints.push_back(ix);
115 const double dy = ypoints.back();
116 uint iy = std::round(dy * sigd) / sigd;
118 ypoints.push_back(iy);
122 rangemaxx = std::make_tuple(xpoints.back(), ypoints.back());
131 const double xscale = 1,
const double yscale = 1)
145 const double sigd = pow(10, pown);
147 for (
const double& d : points)
152 uint itrunc(dn * sigd);
153 npoints.push_back(itrunc / sigd);
156 npoints.push_back(dn);
165 auto [ x1, y1 ] = p1;
166 auto [ x2, y2 ] = p2;
167 auto distancex = (x2 - x1) * (x2 - x1);
168 auto distancey = (y2 - y1) * (y2 - y1);
169 space_type distance = sqrt(distancex + distancey);
193 Point(
double x = 0,
double y = 0,
const std::string s =
"")
198 {
return std::hypot(
x - other.
x,
y - other.
y); }
202 {
return x == other.
x &&
y == other.
y; }
206 {
return Point(
x + other.
x,
y + other.
y); }
210 {
return Point(
x / scalar,
y / scalar); }
219 :
pt(p.x, p.y, p.name),
weight(w) { }
233 outpoints.reserve(inpoints.size());
236 {
auto [ s,
pt ] = p;
auto [
x, y] =
pt;
return Point(
x, y, s); };
237 std::ranges::transform(inpoints, std::back_inserter(outpoints), lconv);
245 using std::make_tuple;
247 outpoints.reserve(inpoints.size());
249 auto lconv = [](
const Point& p){
auto pt = make_tuple(p.x, p.y);
return make_tuple(p.name,
pt); };
250 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.
std::tuple< space_type, space_type, space_type > point_3t
Point (x,y,z) in 3D space, space_type defaults to double.
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)