libstp
Robotics library for Botball
Loading...
Searching...
No Matches
math.hpp
Go to the documentation of this file.
1#pragma once
2#include <functional>
3#include "pch.hpp"
4
6constexpr double RAD_TO_DEG = 180.0 / M_PI;
7constexpr double DEG_TO_RAD = M_PI / 180.0;
8
9namespace libstp::math {
10 using InterpolationFunction = std::function<float(float, float, float)>;
11
13 float lerp(float a, float b, float t);
14
16 float easeInOut(float a, float b, float t);
17
19 float clampf(float value, float min, float max);
20
22 double clampDouble(double value, double min, double max);
23
25 int clampInt(int value, int min, int max);
26
28 int sign(int value);
29
31 float signf(float value);
32
34 float minimalAngleDifference(float a, float b);
35
37 std::tuple<double, double, double> quaternionToEuler(Eigen::Quaterniond q);
38}
constexpr double DEG_TO_RAD
Definition math.hpp:7
constexpr double RAD_TO_DEG
Angle conversion helpers shared across robotics code.
Definition math.hpp:6
std::tuple< double, double, double > quaternionToEuler(Eigen::Quaterniond q)
Convert a quaternion to roll, pitch, yaw in radians.
float lerp(float a, float b, float t)
Linear interpolation between a and b for parameter t.
double clampDouble(double value, double min, double max)
Clamp a double to the inclusive range [min, max].
int clampInt(int value, int min, int max)
Clamp an integer to the inclusive range [min, max].
float minimalAngleDifference(float a, float b)
Return the smallest absolute angular separation between a and b in radians.
float easeInOut(float a, float b, float t)
Cosine-smoothed interpolation between a and b for parameter t.
std::function< float(float, float, float)> InterpolationFunction
Definition math.hpp:10
int sign(int value)
Return -1, 0, or 1 depending on the sign of value.
float clampf(float value, float min, float max)
Clamp a float to the inclusive range [min, max].
float signf(float value)
Return -1.0f, 0.0f, or 1.0f depending on the sign of value.