Apollo  6.0
Open source self driving car software
i_constant.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
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 #pragma once
17 
18 namespace apollo {
19 namespace perception {
20 namespace common {
21 template <typename T>
22 class Constant;
23 
24 template <>
25 class Constant<double> {
26  public:
27  static const double PI() { return 3.1415926535897932384626433832795; } // pi
28  static const double TWO_PI() {
29  return 6.283185307179586476925286766559;
30  } // 2pi
31  static const double HALF_PI() {
32  return 1.5707963267948966192313216916398;
33  } // pi over 2
34  static const double REC_TWO_PI() {
35  return 0.15915494309189533576888376337251;
36  } // reciprocal of 2pi
37  static const double SQRT_2() {
38  return 1.4142135623730950488016887242097;
39  } // square root of 2
40  static const double REC_SQRT_2() {
41  return 0.70710678118654752440084436210485;
42  } // reciprocal of square root of 2
43  static const double SQRT_3() {
44  return 1.7320508075688772935274463415059;
45  } // square root of 3
46  static const double REC_SQRT_3() {
47  return 0.57735026918962576450914878050196;
48  } // reciprocal of square root of 3
49  static const double DEGREE_TO_RADIAN() {
50  return 0.017453292519943295769236907684886;
51  } // 2pi over 360
52  static const double RADIAN_TO_DEGREE() {
53  return 57.295779513082320876798154814105;
54  } // 360 over 2pi
55  static const double EPSILON() { return 1.11e-016; }
56  static const double SQRT_EPSILON() {
57  return 1.053e-08;
58  } // square root of epsilon
59 
60  static const double MIN_ABS_SAFE_DIVIDEND() { return 1e-8; }
61 };
62 
63 template <>
64 class Constant<float> {
65  public:
66  static const float PI() { return 3.1415926535897932384626433832795f; } // pi
67  static const float TWO_PI() {
68  return 6.283185307179586476925286766559f;
69  } // 2pi
70  static const float HALF_PI() {
71  return 1.5707963267948966192313216916398f;
72  } // pi over 2
73  static const float REC_TWO_PI() {
74  return 0.15915494309189533576888376337251f;
75  } // reciprocal of 2pi
76  static const float SQRT_2() {
77  return 1.4142135623730950488016887242097f;
78  } // square root of 2
79  static const float REC_SQRT_2() {
80  return 0.70710678118654752440084436210485f;
81  } // reciprocal of square root of 2
82  static const float SQRT_3() {
83  return 1.7320508075688772935274463415059f;
84  } // square root of 3
85  static const float REC_SQRT_3() {
86  return 0.57735026918962576450914878050196f;
87  } // reciprocal of square root of 3
88  static const float DEGREE_TO_RADIAN() {
89  return 0.017453292519943295769236907684886f;
90  } // 2pi over 360
91  static const float RADIAN_TO_DEGREE() {
92  return 57.295779513082320876798154814105f;
93  } // 360 over 2pi
94  static const float EPSILON() { return 5.96e-08f; }
95  static const float SQRT_EPSILON() {
96  return 2.44e-04f;
97  } // square root of epsilon
98 
99  static const float MIN_ABS_SAFE_DIVIDEND() { return 1e-8f; }
100 };
101 
102 // the look-up table for doing fast bit count (# f 1s) in an unsigned byte
103 static const int kIUByteBitCountLut[] = {
104  0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4,
105  2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
106  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4,
107  2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
108  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
109  4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
110  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5,
111  3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
112  2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
113  4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
114  4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8};
115 
116 } // namespace common
117 } // namespace perception
118 } // namespace apollo
static const double SQRT_3()
Definition: i_constant.h:43
static const double REC_SQRT_2()
Definition: i_constant.h:40
static const double PI()
Definition: i_constant.h:27
static const float EPSILON()
Definition: i_constant.h:94
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
static const double HALF_PI()
Definition: i_constant.h:31
static const float REC_SQRT_2()
Definition: i_constant.h:79
static const float SQRT_EPSILON()
Definition: i_constant.h:95
static const float REC_SQRT_3()
Definition: i_constant.h:85
static const double RADIAN_TO_DEGREE()
Definition: i_constant.h:52
Definition: i_constant.h:22
static const float REC_TWO_PI()
Definition: i_constant.h:73
static const float RADIAN_TO_DEGREE()
Definition: i_constant.h:91
static const double TWO_PI()
Definition: i_constant.h:28
static const double EPSILON()
Definition: i_constant.h:55
static const float SQRT_2()
Definition: i_constant.h:76
static const double REC_SQRT_3()
Definition: i_constant.h:46
static const double DEGREE_TO_RADIAN()
Definition: i_constant.h:49
static const float SQRT_3()
Definition: i_constant.h:82
static const double MIN_ABS_SAFE_DIVIDEND()
Definition: i_constant.h:60
static const float DEGREE_TO_RADIAN()
Definition: i_constant.h:88
static const float HALF_PI()
Definition: i_constant.h:70
static const double SQRT_2()
Definition: i_constant.h:37
static const double REC_TWO_PI()
Definition: i_constant.h:34
static const double SQRT_EPSILON()
Definition: i_constant.h:56
static const float MIN_ABS_SAFE_DIVIDEND()
Definition: i_constant.h:99
static const float TWO_PI()
Definition: i_constant.h:67
static const float PI()
Definition: i_constant.h:66