WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
MathUtil.hpp File Reference
#include <numbers>
#include <type_traits>
#include <gcem.hpp>
#include "wpi/math/geometry/Translation2d.hpp"
#include "wpi/math/geometry/Translation3d.hpp"
#include "wpi/math/util/MathShared.hpp"
#include "wpi/units/angle.hpp"
#include "wpi/units/base.hpp"
#include "wpi/units/length.hpp"
#include "wpi/units/math.hpp"
#include "wpi/units/time.hpp"
#include "wpi/units/velocity.hpp"
#include "wpi/util/SymbolExports.hpp"

Go to the source code of this file.

Namespaces

namespace  wpi
namespace  wpi::math

Functions

template<typename T>
requires std::is_arithmetic_v<T> || wpi::units::traits::is_unit_t_v<T>
constexpr T wpi::math::ApplyDeadband (T value, T deadband, T maxMagnitude=T{1.0})
 Returns 0.0 if the given value is within the specified range around zero.
template<typename T, int N>
requires std::is_arithmetic_v<T> || wpi::units::traits::is_unit_t_v<T>
Eigen::Vector< T, N > wpi::math::ApplyDeadband (const Eigen::Vector< T, N > &value, T deadband, T maxMagnitude=T{1.0})
 Returns a zero vector if the given vector is within the specified distance from the origin.
template<typename T>
requires std::is_arithmetic_v<T> || wpi::units::traits::is_unit_t_v<T>
constexpr T wpi::math::CopyDirectionPow (T value, double exponent, T maxMagnitude=T{1.0})
 Raises the input to the power of the given exponent while preserving its sign.
template<typename T, int N>
requires std::is_arithmetic_v<T> || wpi::units::traits::is_unit_t_v<T>
Eigen::Vector< T, N > wpi::math::CopyDirectionPow (const Eigen::Vector< T, N > &value, double exponent, T maxMagnitude=T{1.0})
 Raises the norm of the input to the power of the given exponent while preserving its direction.
template<typename T>
constexpr T wpi::math::InputModulus (T input, T minimumInput, T maximumInput)
 Returns modulus of input.
template<typename T>
requires std::is_arithmetic_v<T> || wpi::units::traits::is_unit_t_v<T>
constexpr bool wpi::math::IsNear (T expected, T actual, T tolerance)
 Checks if the given value matches an expected value within a certain tolerance.
template<typename T>
requires std::is_arithmetic_v<T> || wpi::units::traits::is_unit_t_v<T>
constexpr bool wpi::math::IsNear (T expected, T actual, T tolerance, T min, T max)
 Checks if the given value matches an expected value within a certain tolerance.
WPILIB_DLLEXPORT constexpr wpi::units::radian_t wpi::math::AngleModulus (wpi::units::radian_t angle)
 Wraps an angle to the range -π to π radians (-180 to 180 degrees).
constexpr std::signed_integral auto wpi::math::FloorDiv (std::signed_integral auto x, std::signed_integral auto y)
 Returns the largest (closest to positive infinity) int value that is less than or equal to the algebraic quotient.
constexpr std::signed_integral auto wpi::math::FloorMod (std::signed_integral auto x, std::signed_integral auto y)
 Returns the floor modulus of the int arguments.
constexpr Translation2d wpi::math::SlewRateLimit (const Translation2d &current, const Translation2d &next, wpi::units::second_t dt, wpi::units::meters_per_second_t maxVelocity)
 Limits translation velocity.
constexpr Translation3d wpi::math::SlewRateLimit (const Translation3d &current, const Translation3d &next, wpi::units::second_t dt, wpi::units::meters_per_second_t maxVelocity)
 Limits translation velocity.