1 #ifndef SLAM_CTOR_CORE_TRIGONOMETRY_UTILS_H 2 #define SLAM_CTOR_CORE_TRIGONOMETRY_UTILS_H 12 virtual double sin(
double angle_rad)
const = 0;
13 virtual double cos(
double angle_rad)
const = 0;
21 double sin(
double angle_rad)
const override {
22 return std::sin(_base_angle + angle_rad);
25 double cos(
double angle_rad)
const override {
26 return std::cos(_base_angle + angle_rad);
30 _base_angle = angle_rad;
40 : _sin_base(0), _cos_base(0)
41 , _angle_min(0), _angle_max(0), _angle_delta(0) {
45 double sin(
double angle_rad)
const override {
47 int angle_idx = std::round((angle_rad - _angle_min) / _angle_delta);
48 return _sin_base * _cos[angle_idx] + _cos_base * _sin[angle_idx];
51 double cos(
double angle_rad)
const override {
53 int angle_idx = std::round((angle_rad - _angle_min) / _angle_delta);
54 return _cos_base * _cos[angle_idx] - _sin_base * _sin[angle_idx];
58 _sin_base = std::sin(angle_rad);
59 _cos_base = std::cos(angle_rad);
62 void update(
double a_min,
double a_max,
double a_inc) {
63 if (a_min == _angle_min && a_max == _angle_max && a_inc == _angle_delta)
71 int angles_nm = (_angle_max - _angle_min) / _angle_delta + 1;
72 _sin.reserve(angles_nm);
73 _cos.reserve(angles_nm);
74 for(
double angle = _angle_min;
angle < _angle_max;
angle += _angle_delta) {
75 _sin.push_back(std::sin(
angle));
76 _cos.push_back(std::cos(
angle));
81 std::vector<double>
_sin, _cos;
void set_base_angle(double angle_rad) override
double cos(double angle_rad) const override
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
std::vector< double > _sin
RawTrigonometryProvider()
void update(double a_min, double a_max, double a_inc)
void set_base_angle(double angle_rad) override
double sin(double angle_rad) const override
virtual void set_base_angle(double angle_rad)=0
virtual double cos(double angle_rad) const =0
double cos(double angle_rad) const override
double sin(double angle_rad) const override
virtual double sin(double angle_rad) const =0
CachedTrigonometryProvider()