41double Sqr(
const double x);
52double CrossProd(
const Vec2d &start_point,
const Vec2d &end_point_1,
53 const Vec2d &end_point_2);
64double InnerProd(
const Vec2d &start_point,
const Vec2d &end_point_1,
65 const Vec2d &end_point_2);
78double CrossProd(
const double x0,
const double y0,
const double x1,
92double InnerProd(
const double x0,
const double y0,
const double x1,
115double AngleDiff(
const double from,
const double to);
124int RandomInt(
const int s,
const int t,
unsigned int rand_seed = 1);
133double RandomDouble(
const double s,
const double t,
unsigned int rand_seed = 1);
142 return value * value;
155T
Clamp(
const T value, T bound1, T bound2) {
156 if (bound1 > bound2) {
157 std::swap(bound1, bound2);
160 if (value < bound1) {
162 }
else if (value > bound2) {
169double Gaussian(
const double u,
const double std,
const double x);
171inline double Sigmoid(
const double x) {
return 1.0 / (1.0 + std::exp(-x)); }
174Eigen::Vector2d
RotateVector2d(
const Eigen::Vector2d &v_in,
const double theta);
176inline std::pair<double, double>
RFUToFLU(
const double x,
const double y) {
177 return std::make_pair(y, -x);
180inline std::pair<double, double>
FLUToRFU(
const double x,
const double y) {
181 return std::make_pair(-y, x);
184inline 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;
210typename 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();
double Sigmoid(const double x)
double Sqr(const double x)
int RandomInt(const int s, const int t, unsigned int rand_seed)
Get a random integer between two integer values by a random seed.
std::pair< double, double > RFUToFLU(const double x, const double y)
std::enable_if<!std::numeric_limits< T >::is_integer, bool >::type almost_equal(T x, T y, int ulp)
double Gaussian(const double u, const double std, const double x)
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 RandomDouble(const double s, const double t, unsigned int rand_seed)
Get a random double between two integer values by a random seed.
T Clamp(const T value, T bound1, T bound2)
Clamp a value between two bounds.
double WrapAngle(const double angle)
Wrap angle to [0, 2 * PI).
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.
std::pair< double, double > Cartesian2Polar(double x, double y)
T Square(const T value)
Compute squared value.
double AngleDiff(const double from, const double to)
Calculate the difference between angle from and to
void L2Norm(int feat_dim, float *feat_data)
double check_negative(double input_data)
std::pair< double, double > FLUToRFU(const double x, const double y)
double NormalizeAngle(const double angle)
Normalize angle to [-PI, PI).
Eigen::Vector2d RotateVector2d(const Eigen::Vector2d &v_in, const double theta)