OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
coordijk.h File Reference

Header file for CoordIJK functions including conversion from lat/lon. More...

+ Include dependency graph for coordijk.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define I_INDEX   0
 
#define J_INDEX   1
 
#define K_INDEX   2
 
#define CoordIJK(variable_name)   int variable_name[3]
 
#define CoordIJK_ptr(variable_name)   int* variable_name
 
#define CoordIJK_clone(ijk)   { ijk[I_INDEX], ijk[J_INDEX], ijk[K_INDEX] }
 
#define CoordIJK_copy(dest_ijk, src_ijk)
 
#define CoordIJKArray(variable_name, size)   int variable_name[size][3]
 

Enumerations

enum  Direction {
  CENTER_DIGIT = 0, K_AXES_DIGIT = 1, J_AXES_DIGIT = 2, JK_AXES_DIGIT = J_AXES_DIGIT | K_AXES_DIGIT,
  I_AXES_DIGIT = 4, IK_AXES_DIGIT = I_AXES_DIGIT | K_AXES_DIGIT, IJ_AXES_DIGIT = I_AXES_DIGIT | J_AXES_DIGIT, INVALID_DIGIT = 7,
  NUM_DIGITS = INVALID_DIGIT
}
 H3 digit representing ijk+ axes direction. Values will be within the lowest 3 bits of an integer. More...
 

Functions

static DEVICE const CoordIJKArray (UNIT_VECS, 7)
 CoordIJK unit vectors corresponding to the 7 H3 digits. More...
 
EXTENSION_INLINE bool _setIJK (CoordIJK(ijk), int i, int j, int k)
 
EXTENSION_NOINLINE bool _hex2dToCoordIJK (const Vec2d(v), CoordIJK(h))
 
EXTENSION_INLINE bool _ijkToHex2d (const CoordIJK(h), Vec2d(v))
 
EXTENSION_INLINE int _ijkMatches (const CoordIJK(c1), const CoordIJK(c2))
 
EXTENSION_INLINE bool _ijkAdd (const CoordIJK(h1), const CoordIJK(h2), CoordIJK(sum))
 
EXTENSION_INLINE bool _ijkSub (const CoordIJK(h1), const CoordIJK(h2), CoordIJK(diff))
 
EXTENSION_INLINE bool _ijkScale (CoordIJK(c), int factor)
 
EXTENSION_NOINLINE bool _ijkNormalize (CoordIJK(c))
 
EXTENSION_NOINLINE int _unitIjkToDigit (const CoordIJK(ijk))
 
EXTENSION_NOINLINE bool _upAp7 (CoordIJK(ijk))
 
EXTENSION_NOINLINE bool _upAp7r (CoordIJK(ijk))
 
EXTENSION_NOINLINE bool _downAp7 (CoordIJK(ijk))
 
EXTENSION_NOINLINE bool _downAp7r (CoordIJK(ijk))
 
EXTENSION_NOINLINE bool _neighbor (CoordIJK(ijk), int digit)
 
EXTENSION_NOINLINE bool _ijkRotate60ccw (CoordIJK(ijk))
 
EXTENSION_NOINLINE bool _ijkRotate60cw (CoordIJK(ijk))
 
EXTENSION_NOINLINE int _rotate60ccw (int digit)
 
EXTENSION_NOINLINE int _rotate60cw (int digit)
 

Detailed Description

Header file for CoordIJK functions including conversion from lat/lon.

References two Vec2d cartesian coordinate systems:

  1. gnomonic: face-centered polyhedral gnomonic projection space with traditional scaling and x-axes aligned with the face Class II i-axes.
  2. hex2d: local face-centered coordinate system scaled a specific H3 grid resolution unit length and with x-axes aligned with the local i-axes

Definition in file coordijk.h.

Macro Definition Documentation

#define CoordIJK (   variable_name)    int variable_name[3]
#define CoordIJK_clone (   ijk)    { ijk[I_INDEX], ijk[J_INDEX], ijk[K_INDEX] }

Definition at line 47 of file coordijk.h.

Referenced by _adjustOverageClassII(), _faceIjkToH3(), _h3ToFaceIjk(), and _unitIjkToDigit().

#define CoordIJK_copy (   dest_ijk,
  src_ijk 
)
Value:
dest_ijk[I_INDEX] = src_ijk[I_INDEX]; \
dest_ijk[J_INDEX] = src_ijk[J_INDEX]; \
dest_ijk[K_INDEX] = src_ijk[K_INDEX];
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44

Definition at line 49 of file coordijk.h.

Referenced by _faceIjkToH3(), and _h3ToFaceIjk().

#define CoordIJK_ptr (   variable_name)    int* variable_name

Definition at line 46 of file coordijk.h.

Referenced by _adjustOverageClassII(), and _faceIjkToH3().

#define CoordIJKArray (   variable_name,
  size 
)    int variable_name[size][3]

Definition at line 53 of file coordijk.h.

Enumeration Type Documentation

enum Direction

H3 digit representing ijk+ axes direction. Values will be within the lowest 3 bits of an integer.

Enumerator
CENTER_DIGIT 

H3 digit in center

K_AXES_DIGIT 

H3 digit in k-axes direction

J_AXES_DIGIT 

H3 digit in j-axes direction

JK_AXES_DIGIT 

H3 digit in j == k direction

I_AXES_DIGIT 

H3 digit in i-axes direction

IK_AXES_DIGIT 

H3 digit in i == k direction

IJ_AXES_DIGIT 

H3 digit in i == j direction

INVALID_DIGIT 

H3 digit in the invalid direction

NUM_DIGITS 

Valid digits will be less than this value. Same value as INVALID_DIGIT.

Definition at line 75 of file coordijk.h.

75  {
77  CENTER_DIGIT = 0,
79  K_AXES_DIGIT = 1,
81  J_AXES_DIGIT = 2,
85  I_AXES_DIGIT = 4,
87  IK_AXES_DIGIT = I_AXES_DIGIT | K_AXES_DIGIT, /* 5 */
89  IJ_AXES_DIGIT = I_AXES_DIGIT | J_AXES_DIGIT, /* 6 */
91  INVALID_DIGIT = 7,
94  NUM_DIGITS = INVALID_DIGIT
95 } Direction;
Direction
H3 digit representing ijk+ axes direction. Values will be within the lowest 3 bits of an integer...
Definition: coordijk.h:75

Function Documentation

EXTENSION_NOINLINE bool _downAp7 ( CoordIJK(ijk)  )

Find the normalized ijk coordinates of the hex centered on the indicated hex at the next finer aperture 7 counter-clockwise resolution. Works in place.

Parameters
ijkThe ijk coordinates.

Definition at line 325 of file coordijk.hpp.

References _ijkAdd(), _ijkNormalize(), _ijkScale(), CoordIJK, I_INDEX, J_INDEX, and K_INDEX.

Referenced by _faceIjkToH3(), and _h3ToFaceIjkWithInitializedFijk().

325  {
326  // res r unit vectors in res r+1
327  CoordIJK(iVec) = {3, 0, 1};
328  CoordIJK(jVec) = {1, 3, 0};
329  CoordIJK(kVec) = {0, 1, 3};
330 
331  _ijkScale(iVec, ijk[I_INDEX]);
332  _ijkScale(jVec, ijk[J_INDEX]);
333  _ijkScale(kVec, ijk[K_INDEX]);
334 
335  _ijkAdd(iVec, jVec, ijk);
336  _ijkAdd(ijk, kVec, ijk);
337 
338  _ijkNormalize(ijk);
339  return true;
340 }
#define J_INDEX
Definition: coordijk.h:43
EXTENSION_INLINE bool _ijkScale(CoordIJK(c), int factor)
Definition: coordijk.hpp:211
EXTENSION_INLINE bool _ijkAdd(const CoordIJK(h1), const CoordIJK(h2), CoordIJK(sum))
Definition: coordijk.hpp:184
#define I_INDEX
Definition: coordijk.h:42
#define CoordIJK(variable_name)
Definition: coordijk.h:45
#define K_INDEX
Definition: coordijk.h:44
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _downAp7r ( CoordIJK(ijk)  )

Find the normalized ijk coordinates of the hex centered on the indicated hex at the next finer aperture 7 clockwise resolution. Works in place.

Parameters
ijkThe ijk coordinates.

Definition at line 348 of file coordijk.hpp.

References _ijkAdd(), _ijkNormalize(), _ijkScale(), CoordIJK, I_INDEX, J_INDEX, and K_INDEX.

Referenced by _faceIjkToH3(), _h3ToFaceIjk(), and _h3ToFaceIjkWithInitializedFijk().

348  {
349  // res r unit vectors in res r+1
350  CoordIJK(iVec) = {3, 1, 0};
351  CoordIJK(jVec) = {0, 3, 1};
352  CoordIJK(kVec) = {1, 0, 3};
353 
354  _ijkScale(iVec, ijk[I_INDEX]);
355  _ijkScale(jVec, ijk[J_INDEX]);
356  _ijkScale(kVec, ijk[K_INDEX]);
357 
358  _ijkAdd(iVec, jVec, ijk);
359  _ijkAdd(ijk, kVec, ijk);
360 
361  _ijkNormalize(ijk);
362  return true;
363 }
#define J_INDEX
Definition: coordijk.h:43
EXTENSION_INLINE bool _ijkScale(CoordIJK(c), int factor)
Definition: coordijk.hpp:211
EXTENSION_INLINE bool _ijkAdd(const CoordIJK(h1), const CoordIJK(h2), CoordIJK(sum))
Definition: coordijk.hpp:184
#define I_INDEX
Definition: coordijk.h:42
#define CoordIJK(variable_name)
Definition: coordijk.h:45
#define K_INDEX
Definition: coordijk.h:44
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _hex2dToCoordIJK ( const   Vec2dv,
CoordIJK(h)   
)

Determine the containing hex in ijk+ coordinates for a 2D cartesian coordinate vector (from DGGRID).

Parameters
vThe 2D cartesian coordinate vector.
hThe ijk+ coordinates of the containing hex.

Definition at line 54 of file coordijk.hpp.

References _ijkNormalize(), I_INDEX, J_INDEX, K_INDEX, M_SIN60, X_INDEX, and Y_INDEX.

Referenced by _geoToFaceIjk().

54  {
55  double a1, a2;
56  double x1, x2;
57  int m1, m2;
58  double r1, r2;
59 
60  // quantize into the ij system and then normalize
61  h[K_INDEX] = 0;
62 
63  a1 = fabs(v[X_INDEX]);
64  a2 = fabs(v[Y_INDEX]);
65 
66  // first do a reverse conversion
67  x2 = a2 / M_SIN60;
68  x1 = a1 + x2 / 2.0;
69 
70  // check if we have the center of a hex
71  m1 = x1;
72  m2 = x2;
73 
74  // otherwise round correctly
75  r1 = x1 - m1;
76  r2 = x2 - m2;
77 
78  if (r1 < 0.5) {
79  if (r1 < 1.0 / 3.0) {
80  if (r2 < (1.0 + r1) / 2.0) {
81  h[I_INDEX] = m1;
82  h[J_INDEX] = m2;
83  } else {
84  h[I_INDEX] = m1;
85  h[J_INDEX] = m2 + 1;
86  }
87  } else {
88  if (r2 < (1.0 - r1)) {
89  h[J_INDEX] = m2;
90  } else {
91  h[J_INDEX] = m2 + 1;
92  }
93 
94  if ((1.0 - r1) <= r2 && r2 < (2.0 * r1)) {
95  h[I_INDEX] = m1 + 1;
96  } else {
97  h[I_INDEX] = m1;
98  }
99  }
100  } else {
101  if (r1 < 2.0 / 3.0) {
102  if (r2 < (1.0 - r1)) {
103  h[J_INDEX] = m2;
104  } else {
105  h[J_INDEX] = m2 + 1;
106  }
107 
108  if ((2.0 * r1 - 1.0) < r2 && r2 < (1.0 - r1)) {
109  h[I_INDEX] = m1;
110  } else {
111  h[I_INDEX] = m1 + 1;
112  }
113  } else {
114  if (r2 < (r1 / 2.0)) {
115  h[I_INDEX] = m1 + 1;
116  h[J_INDEX] = m2;
117  } else {
118  h[I_INDEX] = m1 + 1;
119  h[J_INDEX] = m2 + 1;
120  }
121  }
122  }
123 
124  // now fold across the axes if necessary
125 
126  if (v[X_INDEX] < 0.0) {
127  if ((h[J_INDEX] % 2) == 0) // even
128  {
129  long long int axisi = h[J_INDEX] / 2;
130  long long int diff = h[I_INDEX] - axisi;
131  h[I_INDEX] = h[I_INDEX] - 2.0 * diff;
132  } else {
133  long long int axisi = (h[J_INDEX] + 1) / 2;
134  long long int diff = h[I_INDEX] - axisi;
135  h[I_INDEX] = h[I_INDEX] - (2.0 * diff + 1);
136  }
137  }
138 
139  if (v[Y_INDEX] < 0.0) {
140  h[I_INDEX] = h[I_INDEX] - (2 * h[J_INDEX] + 1) / 2;
141  h[J_INDEX] = -1 * h[J_INDEX];
142  }
143 
144  _ijkNormalize(h);
145 
146  return true;
147 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define X_INDEX
Definition: vec2d.h:26
#define K_INDEX
Definition: coordijk.h:44
#define Y_INDEX
Definition: vec2d.h:27
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224
#define M_SIN60
Definition: constants.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE bool _ijkAdd ( const   CoordIJKh1,
const   CoordIJKh2,
CoordIJK(sum)   
)

Add two ijk coordinates.

Parameters
h1The first set of ijk coordinates.
h2The second set of ijk coordinates.
sumThe sum of the two sets of ijk coordinates.

Definition at line 184 of file coordijk.hpp.

References I_INDEX, J_INDEX, and K_INDEX.

Referenced by _adjustOverageClassII(), _downAp7(), _downAp7r(), _ijkRotate60ccw(), _ijkRotate60cw(), and _neighbor().

184  {
185  sum[I_INDEX] = h1[I_INDEX] + h2[I_INDEX];
186  sum[J_INDEX] = h1[J_INDEX] + h2[J_INDEX];
187  sum[K_INDEX] = h1[K_INDEX] + h2[K_INDEX];
188  return true;
189 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44

+ Here is the caller graph for this function:

EXTENSION_INLINE int _ijkMatches ( const   CoordIJKc1,
const   CoordIJKc2 
)

Returns whether or not two ijk coordinates contain exactly the same component values.

Parameters
c1The first set of ijk coordinates.
c2The second set of ijk coordinates.
Returns
1 if the two addresses match, 0 if they do not.

Definition at line 172 of file coordijk.hpp.

References I_INDEX, J_INDEX, and K_INDEX.

Referenced by _unitIjkToDigit().

172  {
173  return (c1[I_INDEX] == c2[I_INDEX] && c1[J_INDEX] == c2[J_INDEX] &&
174  c1[K_INDEX] == c2[K_INDEX]);
175 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _ijkNormalize ( CoordIJK(c)  )

Normalizes ijk coordinates by setting the components to the smallest possible values. Works in place.

Parameters
cThe ijk coordinates to normalize.

Definition at line 224 of file coordijk.hpp.

References I_INDEX, J_INDEX, and K_INDEX.

Referenced by _adjustOverageClassII(), _downAp7(), _downAp7r(), _faceIjkToH3(), _hex2dToCoordIJK(), _ijkRotate60ccw(), _ijkRotate60cw(), _neighbor(), _unitIjkToDigit(), _upAp7(), and _upAp7r().

224  {
225  // remove any negative values
226  if (c[I_INDEX] < 0) {
227  c[J_INDEX] -= c[I_INDEX];
228  c[K_INDEX] -= c[I_INDEX];
229  c[I_INDEX] = 0;
230  }
231 
232  if (c[J_INDEX] < 0) {
233  c[I_INDEX] -= c[J_INDEX];
234  c[K_INDEX] -= c[J_INDEX];
235  c[J_INDEX] = 0;
236  }
237 
238  if (c[K_INDEX] < 0) {
239  c[I_INDEX] -= c[K_INDEX];
240  c[J_INDEX] -= c[K_INDEX];
241  c[K_INDEX] = 0;
242  }
243 
244  // remove the min value if needed
245  int min = c[I_INDEX];
246  if (c[J_INDEX] < min)
247  min = c[J_INDEX];
248  if (c[K_INDEX] < min)
249  min = c[K_INDEX];
250  if (min > 0) {
251  c[I_INDEX] -= min;
252  c[J_INDEX] -= min;
253  c[K_INDEX] -= min;
254  }
255 
256  return true;
257 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _ijkRotate60ccw ( CoordIJK(ijk)  )

Rotates ijk coordinates 60 degrees counter-clockwise. Works in place.

Parameters
ijkThe ijk coordinates.

Definition at line 385 of file coordijk.hpp.

References _ijkAdd(), _ijkNormalize(), _ijkScale(), CoordIJK, I_INDEX, J_INDEX, and K_INDEX.

Referenced by _adjustOverageClassII().

385  {
386  // unit vector rotations
387  CoordIJK(iVec) = {1, 1, 0};
388  CoordIJK(jVec) = {0, 1, 1};
389  CoordIJK(kVec) = {1, 0, 1};
390 
391  _ijkScale(iVec, ijk[I_INDEX]);
392  _ijkScale(jVec, ijk[J_INDEX]);
393  _ijkScale(kVec, ijk[K_INDEX]);
394 
395  _ijkAdd(iVec, jVec, ijk);
396  _ijkAdd(ijk, kVec, ijk);
397 
398  _ijkNormalize(ijk);
399  return true;
400 }
#define J_INDEX
Definition: coordijk.h:43
EXTENSION_INLINE bool _ijkScale(CoordIJK(c), int factor)
Definition: coordijk.hpp:211
EXTENSION_INLINE bool _ijkAdd(const CoordIJK(h1), const CoordIJK(h2), CoordIJK(sum))
Definition: coordijk.hpp:184
#define I_INDEX
Definition: coordijk.h:42
#define CoordIJK(variable_name)
Definition: coordijk.h:45
#define K_INDEX
Definition: coordijk.h:44
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _ijkRotate60cw ( CoordIJK(ijk)  )

Rotates ijk coordinates 60 degrees clockwise. Works in place.

Parameters
ijkThe ijk coordinates.

Definition at line 407 of file coordijk.hpp.

References _ijkAdd(), _ijkNormalize(), _ijkScale(), CoordIJK, I_INDEX, J_INDEX, and K_INDEX.

Referenced by _adjustOverageClassII().

407  {
408  // unit vector rotations
409  CoordIJK(iVec) = {1, 0, 1};
410  CoordIJK(jVec) = {1, 1, 0};
411  CoordIJK(kVec) = {0, 1, 1};
412 
413  _ijkScale(iVec, ijk[I_INDEX]);
414  _ijkScale(jVec, ijk[J_INDEX]);
415  _ijkScale(kVec, ijk[K_INDEX]);
416 
417  _ijkAdd(iVec, jVec, ijk);
418  _ijkAdd(ijk, kVec, ijk);
419 
420  _ijkNormalize(ijk);
421  return true;
422 }
#define J_INDEX
Definition: coordijk.h:43
EXTENSION_INLINE bool _ijkScale(CoordIJK(c), int factor)
Definition: coordijk.hpp:211
EXTENSION_INLINE bool _ijkAdd(const CoordIJK(h1), const CoordIJK(h2), CoordIJK(sum))
Definition: coordijk.hpp:184
#define I_INDEX
Definition: coordijk.h:42
#define CoordIJK(variable_name)
Definition: coordijk.h:45
#define K_INDEX
Definition: coordijk.h:44
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_INLINE bool _ijkScale ( CoordIJK(c)  ,
int  factor 
)

Uniformly scale ijk coordinates by a scalar. Works in place.

Parameters
cThe ijk coordinates to scale.
factorThe scaling factor.

Definition at line 211 of file coordijk.hpp.

References I_INDEX, J_INDEX, and K_INDEX.

Referenced by _adjustOverageClassII(), _downAp7(), _downAp7r(), _ijkRotate60ccw(), and _ijkRotate60cw().

211  {
212  c[I_INDEX] *= factor;
213  c[J_INDEX] *= factor;
214  c[K_INDEX] *= factor;
215  return true;
216 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44

+ Here is the caller graph for this function:

EXTENSION_INLINE bool _ijkSub ( const   CoordIJKh1,
const   CoordIJKh2,
CoordIJK(diff)   
)

Subtract two ijk coordinates.

Parameters
h1The first set of ijk coordinates.
h2The second set of ijk coordinates.
diffThe difference of the two sets of ijk coordinates (h1 - h2).

Definition at line 198 of file coordijk.hpp.

References I_INDEX, J_INDEX, and K_INDEX.

Referenced by _adjustOverageClassII(), and _faceIjkToH3().

198  {
199  diff[I_INDEX] = h1[I_INDEX] - h2[I_INDEX];
200  diff[J_INDEX] = h1[J_INDEX] - h2[J_INDEX];
201  diff[K_INDEX] = h1[K_INDEX] - h2[K_INDEX];
202  return true;
203 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44

+ Here is the caller graph for this function:

EXTENSION_INLINE bool _ijkToHex2d ( const   CoordIJKh,
Vec2d(v)   
)

Find the center point in 2D cartesian coordinates of a hex.

Parameters
hThe ijk coordinates of the hex.
vThe 2D cartesian coordinates of the hex center point.

Definition at line 155 of file coordijk.hpp.

References i, I_INDEX, J_INDEX, K_INDEX, M_SQRT3_2, X_INDEX, and Y_INDEX.

Referenced by _faceIjkToGeo().

155  {
156  int i = h[I_INDEX] - h[K_INDEX];
157  int j = h[J_INDEX] - h[K_INDEX];
158 
159  v[X_INDEX] = i - 0.5 * j;
160  v[Y_INDEX] = j * M_SQRT3_2;
161  return true;
162 }
#define J_INDEX
Definition: coordijk.h:43
#define M_SQRT3_2
Definition: constants.h:44
#define I_INDEX
Definition: coordijk.h:42
#define X_INDEX
Definition: vec2d.h:26
#define K_INDEX
Definition: coordijk.h:44
#define Y_INDEX
Definition: vec2d.h:27

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _neighbor ( CoordIJK(ijk)  ,
int  digit 
)

Find the normalized ijk coordinates of the hex in the specified digit direction from the specified ijk coordinates. Works in place.

Parameters
ijkThe ijk coordinates.
digitThe digit direction from the original ijk coordinates.

Definition at line 372 of file coordijk.hpp.

References _ijkAdd(), _ijkNormalize(), CENTER_DIGIT, and NUM_DIGITS.

Referenced by _h3ToFaceIjkWithInitializedFijk().

372  {
373  if (digit > CENTER_DIGIT && digit < NUM_DIGITS) {
374  _ijkAdd(ijk, UNIT_VECS[digit], ijk);
375  _ijkNormalize(ijk);
376  }
377  return true;
378 }
EXTENSION_INLINE bool _ijkAdd(const CoordIJK(h1), const CoordIJK(h2), CoordIJK(sum))
Definition: coordijk.hpp:184
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE int _rotate60ccw ( int  digit)

Rotates indexing digit 60 degrees counter-clockwise. Returns result.

Parameters
digitIndexing digit (between 1 and 6 inclusive)

Definition at line 429 of file coordijk.hpp.

References I_AXES_DIGIT, IJ_AXES_DIGIT, IK_AXES_DIGIT, J_AXES_DIGIT, JK_AXES_DIGIT, and K_AXES_DIGIT.

Referenced by _h3Rotate60ccw(), and _h3RotatePent60ccw().

429  {
430  switch (Direction(digit)) {
431  case K_AXES_DIGIT:
432  return IK_AXES_DIGIT;
433  case IK_AXES_DIGIT:
434  return I_AXES_DIGIT;
435  case I_AXES_DIGIT:
436  return IJ_AXES_DIGIT;
437  case IJ_AXES_DIGIT:
438  return J_AXES_DIGIT;
439  case J_AXES_DIGIT:
440  return JK_AXES_DIGIT;
441  case JK_AXES_DIGIT:
442  return K_AXES_DIGIT;
443  default:
444  return digit;
445  }
446 }
Direction
H3 digit representing ijk+ axes direction. Values will be within the lowest 3 bits of an integer...
Definition: coordijk.h:75

+ Here is the caller graph for this function:

EXTENSION_NOINLINE int _rotate60cw ( int  digit)

Rotates indexing digit 60 degrees clockwise. Returns result.

Parameters
digitIndexing digit (between 1 and 6 inclusive)

Definition at line 453 of file coordijk.hpp.

References I_AXES_DIGIT, IJ_AXES_DIGIT, IK_AXES_DIGIT, J_AXES_DIGIT, JK_AXES_DIGIT, and K_AXES_DIGIT.

Referenced by _h3Rotate60cw(), and _h3RotatePent60cw().

453  {
454  switch (Direction(digit)) {
455  case K_AXES_DIGIT:
456  return JK_AXES_DIGIT;
457  case JK_AXES_DIGIT:
458  return J_AXES_DIGIT;
459  case J_AXES_DIGIT:
460  return IJ_AXES_DIGIT;
461  case IJ_AXES_DIGIT:
462  return I_AXES_DIGIT;
463  case I_AXES_DIGIT:
464  return IK_AXES_DIGIT;
465  case IK_AXES_DIGIT:
466  return K_AXES_DIGIT;
467  default:
468  return digit;
469  }
470 }
Direction
H3 digit representing ijk+ axes direction. Values will be within the lowest 3 bits of an integer...
Definition: coordijk.h:75

+ Here is the caller graph for this function:

EXTENSION_INLINE bool _setIJK ( CoordIJK(ijk)  ,
int  i,
int  j,
int  k 
)

Sets an IJK coordinate to the specified component values.

Parameters
ijkThe IJK coordinate to set.
iThe desired i component value.
jThe desired j component value.
kThe desired k component value.

Definition at line 40 of file coordijk.hpp.

References i, I_INDEX, J_INDEX, and K_INDEX.

Referenced by _adjustOverageClassII().

40  {
41  ijk[I_INDEX] = i;
42  ijk[J_INDEX] = j;
43  ijk[K_INDEX] = k;
44  return true;
45 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44

+ Here is the caller graph for this function:

EXTENSION_NOINLINE int _unitIjkToDigit ( const   CoordIJKijk)

Determines the H3 digit corresponding to a unit vector in ijk coordinates.

Parameters
ijkThe ijk coordinates; must be a unit vector.
Returns
The H3 digit (0-6) corresponding to the ijk unit vector, or INVALID_DIGIT on failure.

Definition at line 266 of file coordijk.hpp.

References _ijkMatches(), _ijkNormalize(), CENTER_DIGIT, CoordIJK, CoordIJK_clone, i, INVALID_DIGIT, and NUM_DIGITS.

Referenced by _faceIjkToH3().

266  {
267  CoordIJK(c) = CoordIJK_clone(ijk);
268  _ijkNormalize(c);
269 
270  Direction digit = INVALID_DIGIT;
271  for (int i = CENTER_DIGIT; i < NUM_DIGITS; i++) {
272  if (_ijkMatches(c, UNIT_VECS[i])) {
273  digit = Direction(i);
274  break;
275  }
276  }
277 
278  return digit;
279 }
EXTENSION_INLINE int _ijkMatches(const CoordIJK(c1), const CoordIJK(c2))
Definition: coordijk.hpp:172
#define CoordIJK_clone(ijk)
Definition: coordijk.h:47
Direction
H3 digit representing ijk+ axes direction. Values will be within the lowest 3 bits of an integer...
Definition: coordijk.h:75
#define CoordIJK(variable_name)
Definition: coordijk.h:45
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _upAp7 ( CoordIJK(ijk)  )

Find the normalized ijk coordinates of the indexing parent of a cell in a counter-clockwise aperture 7 grid. Works in place.

Parameters
ijkThe ijk coordinates.

Definition at line 287 of file coordijk.hpp.

References _ijkNormalize(), i, I_INDEX, J_INDEX, and K_INDEX.

Referenced by _faceIjkToH3().

287  {
288  // convert to CoordIJ
289  int i = ijk[I_INDEX] - ijk[K_INDEX];
290  int j = ijk[J_INDEX] - ijk[K_INDEX];
291 
292  ijk[I_INDEX] = (int)lround((3 * i - j) / 7.0);
293  ijk[J_INDEX] = (int)lround((i + 2 * j) / 7.0);
294  ijk[K_INDEX] = 0;
295  _ijkNormalize(ijk);
296 
297  return true;
298 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

EXTENSION_NOINLINE bool _upAp7r ( CoordIJK(ijk)  )

Find the normalized ijk coordinates of the indexing parent of a cell in a clockwise aperture 7 grid. Works in place.

Parameters
ijkThe ijk coordinates.

Definition at line 306 of file coordijk.hpp.

References _ijkNormalize(), i, I_INDEX, J_INDEX, and K_INDEX.

Referenced by _faceIjkToH3(), and _h3ToFaceIjk().

306  {
307  // convert to CoordIJ
308  int i = ijk[I_INDEX] - ijk[K_INDEX];
309  int j = ijk[J_INDEX] - ijk[K_INDEX];
310 
311  ijk[I_INDEX] = (int)lround((2 * i + j) / 7.0);
312  ijk[J_INDEX] = (int)lround((3 * j - i) / 7.0);
313  ijk[K_INDEX] = 0;
314  _ijkNormalize(ijk);
315  return true;
316 }
#define J_INDEX
Definition: coordijk.h:43
#define I_INDEX
Definition: coordijk.h:42
#define K_INDEX
Definition: coordijk.h:44
EXTENSION_NOINLINE bool _ijkNormalize(CoordIJK(c))
Definition: coordijk.hpp:224

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static DEVICE const CoordIJKArray ( UNIT_VECS  ,
 
)
static

CoordIJK unit vectors corresponding to the 7 H3 digits.