26 #include <type_traits> 29 #include "Eigen/Dense" 41 double Sqr(
const double x);
52 double CrossProd(
const Vec2d &start_point,
const Vec2d &end_point_1,
53 const Vec2d &end_point_2);
64 double InnerProd(
const Vec2d &start_point,
const Vec2d &end_point_1,
65 const Vec2d &end_point_2);
78 double CrossProd(
const double x0,
const double y0,
const double x1,
92 double InnerProd(
const double x0,
const double y0,
const double x1,
115 double AngleDiff(
const double from,
const double to);
124 int RandomInt(
const int s,
const int t,
unsigned int rand_seed = 1);
133 double RandomDouble(
const double s,
const double t,
unsigned int rand_seed = 1);
140 template <
typename T>
142 return value *
value;
154 template <
typename T>
156 if (bound1 > bound2) {
157 std::swap(bound1, bound2);
160 if (value < bound1) {
162 }
else if (value > bound2) {
169 double Gaussian(
const double u,
const double std,
const double x);
171 inline double Sigmoid(
const double x) {
return 1.0 / (1.0 + std::exp(-x)); }
176 inline std::pair<double, double>
RFUToFLU(
const double x,
const double y) {
177 return std::make_pair(y, -x);
180 inline std::pair<double, double>
FLUToRFU(
const double x,
const double y) {
181 return std::make_pair(-y, x);
184 inline void L2Norm(
int feat_dim,
float *feat_data) {
190 for (
int i = 0; i < feat_dim; ++i) {
191 l2norm += feat_data[i] * feat_data[i];
194 float val = 1.f / std::sqrt(static_cast<float>(feat_dim));
195 for (
int i = 0; i < feat_dim; ++i) {
199 l2norm = std::sqrt(l2norm);
200 for (
int i = 0; i < feat_dim; ++i) {
201 feat_data[i] /= l2norm;
210 typename std::enable_if<!std::numeric_limits<T>::is_integer,
bool>::type
215 return std::fabs(x - y) <=
216 std::numeric_limits<T>::epsilon() * std::fabs(x + y) * ulp ||
217 std::fabs(x - y) < std::numeric_limits<T>::min();
void L2Norm(int feat_dim, float *feat_data)
Definition: math_utils.h:184
double Sqr(const double x)
double Gaussian(const double u, const double std, const double x)
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
Eigen::Vector2d Vector2d
Definition: base_map_fwd.h:36
double WrapAngle(const double angle)
Wrap angle to [0, 2 * PI).
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
int RandomInt(const int s, const int t, unsigned int rand_seed=1)
Get a random integer between two integer values by a random seed.
double AngleDiff(const double from, const double to)
Calculate the difference between angle from and to.
double Sigmoid(const double x)
Definition: math_utils.h:171
T Square(const T value)
Compute squared value.
Definition: math_utils.h:141
std::pair< double, double > FLUToRFU(const double x, const double y)
Definition: math_utils.h:180
T Clamp(const T value, T bound1, T bound2)
Clamp a value between two bounds. If the value goes beyond the bounds, return one of the bounds...
Definition: math_utils.h:155
std::pair< double, double > Cartesian2Polar(double x, double y)
std::pair< double, double > RFUToFLU(const double x, const double y)
Definition: math_utils.h:176
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
Definition: math_utils.h:211
apollo::cyber::base::std value
double CrossProd(const Vec2d &start_point, const Vec2d &end_point_1, const Vec2d &end_point_2)
Cross product between two 2-D vectors from the common start point, and end at two other points...
double InnerProd(const Vec2d &start_point, const Vec2d &end_point_1, const Vec2d &end_point_2)
Inner product between two 2-D vectors from the common start point, and end at two other points...
Eigen::Vector2d RotateVector2d(const Eigen::Vector2d &v_in, const double theta)
double RandomDouble(const double s, const double t, unsigned int rand_seed=1)
Get a random double between two integer values by a random seed.