| 1 | /* |
| 2 | * Copyright 2016-2017 Uber Technologies, Inc. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | /** @file constants.h |
| 17 | * @brief Constants used by more than one source code file. |
| 18 | */ |
| 19 | |
| 20 | #ifndef CONSTANTS_H |
| 21 | #define CONSTANTS_H |
| 22 | |
| 23 | #ifndef M_PI |
| 24 | /** pi */ |
| 25 | #define M_PI 3.14159265358979323846 |
| 26 | #endif |
| 27 | |
| 28 | #ifndef M_PI_2 |
| 29 | /** pi / 2.0 */ |
| 30 | #define M_PI_2 1.5707963267948966 |
| 31 | #endif |
| 32 | |
| 33 | /** 2.0 * PI */ |
| 34 | #define M_2PI 6.28318530717958647692528676655900576839433L |
| 35 | |
| 36 | /** pi / 180 */ |
| 37 | #define M_PI_180 0.0174532925199432957692369076848861271111L |
| 38 | /** pi * 180 */ |
| 39 | #define M_180_PI 57.29577951308232087679815481410517033240547L |
| 40 | |
| 41 | /** threshold epsilon */ |
| 42 | #define EPSILON 0.0000000000000001L |
| 43 | /** sqrt(3) / 2.0 */ |
| 44 | #define M_SQRT3_2 0.8660254037844386467637231707529361834714L |
| 45 | /** sin(60') */ |
| 46 | #define M_SIN60 M_SQRT3_2 |
| 47 | |
| 48 | /** rotation angle between Class II and Class III resolution axes |
| 49 | * (asin(sqrt(3.0 / 28.0))) */ |
| 50 | #define M_AP7_ROT_RADS 0.333473172251832115336090755351601070065900389L |
| 51 | |
| 52 | /** sin(M_AP7_ROT_RADS) */ |
| 53 | #define M_SIN_AP7_ROT 0.3273268353539885718950318L |
| 54 | |
| 55 | /** cos(M_AP7_ROT_RADS) */ |
| 56 | #define M_COS_AP7_ROT 0.9449111825230680680167902L |
| 57 | |
| 58 | /** earth radius in kilometers using WGS84 authalic radius */ |
| 59 | #define EARTH_RADIUS_KM 6371.007180918475L |
| 60 | |
| 61 | /** scaling factor from hex2d resolution 0 unit length |
| 62 | * (or distance between adjacent cell center points |
| 63 | * on the plane) to gnomonic unit length. */ |
| 64 | #define RES0_U_GNOMONIC 0.38196601125010500003L |
| 65 | |
| 66 | /** max H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15 */ |
| 67 | #define MAX_H3_RES 15 |
| 68 | |
| 69 | /** The number of faces on an icosahedron */ |
| 70 | #define NUM_ICOSA_FACES 20 |
| 71 | /** The number of H3 base cells */ |
| 72 | #define NUM_BASE_CELLS 122 |
| 73 | /** The number of vertices in a hexagon */ |
| 74 | #define NUM_HEX_VERTS 6 |
| 75 | /** The number of vertices in a pentagon */ |
| 76 | #define NUM_PENT_VERTS 5 |
| 77 | |
| 78 | /** H3 index modes */ |
| 79 | #define H3_HEXAGON_MODE 1 |
| 80 | #define H3_UNIEDGE_MODE 2 |
| 81 | |
| 82 | #endif |
| 83 | |