40UnitVector3d
const & rootVertex(
int r,
int i) {
41 static UnitVector3d
const VERTICES[8][3] = {
51 return VERTICES[r][i];
55template <
typename RegionType,
bool InteriorOnly>
56class HtmPixelFinder:
public detail::PixelFinder<
57 HtmPixelFinder<RegionType, InteriorOnly>, RegionType, InteriorOnly, 3>
59 using Base = detail::PixelFinder<
60 HtmPixelFinder<RegionType, InteriorOnly>, RegionType, InteriorOnly, 3>;
64 HtmPixelFinder(RangeSet & ranges,
65 RegionType
const & region,
68 Base(ranges, region, level, maxRanges)
72 UnitVector3d trixel[3];
74 for (uint64_t r = 0; r < 8; ++r) {
75 for (
int v = 0; v < 3; ++v) {
76 trixel[v] = rootVertex(r, v);
78 visit(trixel, r + 8, 0);
82 void subdivide(UnitVector3d
const * trixel, uint64_t index,
int level) {
83 UnitVector3d mid[3] = {
84 UnitVector3d(trixel[1] + trixel[2]),
85 UnitVector3d(trixel[2] + trixel[0]),
86 UnitVector3d(trixel[0] + trixel[1])
88 UnitVector3d child[3] = {trixel[0], mid[2], mid[1]};
91 visit(child, index, level);
96 visit(child, index, level);
101 visit(child, index, level);
103 visit(mid, index, level);
117 if ((j & 1) == 0 || (j == 1)) {
129 uint64_t r = (i >> l) & 7;
133 for (l -= 2; l >= 0; l -= 2) {
134 int child = (i >> l) & 3;
139 case 0: v1 = m01; v2 = m20;
break;
140 case 1: v0 = v1; v1 = m12; v2 = m01;
break;
141 case 2: v0 = v2; v1 = m20; v2 = m12;
break;
142 case 3: v0 = m12; v1 = m20; v2 = m01;
break;
155 char * p = s + (
sizeof(s) - 1);
156 for (; l >= 0; --l, --p, i >>= 2) {
160 *p = (i & 1) == 0 ?
'S' :
'N';
161 return std::string(p,
sizeof(s) -
static_cast<size_t>(p - s));
176 r = (v.
x() > 0.0) ? 0 : 1;
177 }
else if (v.
y() == 0.0) {
178 r = (v.
x() >= 0.0) ? 0 : 2;
180 r = (v.
x() < 0.0) ? 2 : 3;
185 r = (v.
x() > 0.0) ? 7 : 6;
186 }
else if (v.
y() == 0.0) {
187 r = (v.
x() >= 0.0) ? 7 : 5;
189 r = (v.
x() < 0.0) ? 5 : 4;
196 for (
int l = 0; l < _level; ++l) {
206 v0 = v1; v1 = m12; v2 = m01;
209 v0 = v2; v1 = m20; v2 = m12;
212 v0 = m12; v1 = m20; v2 = m01;
220 return detail::findPixels<HtmPixelFinder, false>(r, maxRanges, _level);
224 return detail::findPixels<HtmPixelFinder, true>(r, maxRanges, _level);
This file declares a Pixelization subclass for the HTM indexing scheme.
This file provides a base class for pixel finders.
ConvexPolygon is a closed convex polygon on the unit sphere.
static constexpr int MAX_LEVEL
MAX_LEVEL is the maximum supported HTM subdivision level.
RangeSet _interior(Region const &, size_t) const override
RangeSet _envelope(Region const &, size_t) const override
uint64_t index(UnitVector3d const &) const override
index computes the index of the pixel for v.
static std::string asString(uint64_t i)
asString converts the given HTM index to a human readable string.
static int level(uint64_t i)
level returns the subdivision level of the given HTM index.
static ConvexPolygon triangle(uint64_t i)
triangle returns the triangle corresponding to the given HTM index.
HtmPixelization(int level)
This constructor creates an HTM pixelization of the sphere with the given subdivision level.
A RangeSet is a set of unsigned 64 bit integers.
Region is a minimal interface for 2-dimensional regions on the unit sphere.
UnitVector3d is a unit vector in ℝ³ with components stored in double precision.
void visit(UnitVector3d const *pixel, uint64_t index, int level)
This file contains functions for space-filling curves.
int orientation(UnitVector3d const &a, UnitVector3d const &b, UnitVector3d const &c)
orientation computes and returns the orientations of 3 unit vectors a, b and c.
This file declares functions for orienting points on the sphere.