Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
math.hpp File Reference

Fixposition SDK: Math utilities. More...

#include <algorithm>
#include <cmath>
#include <cstdint>
Include dependency graph for math.hpp:

Go to the source code of this file.

Namespaces

namespace  fpsdk
 Fixposition SDK.
 
namespace  fpsdk::common
 Fixposition SDK: Common library.
 
namespace  fpsdk::common::math
 Math utilities.
 

Functions

template<typename T >
constexpr T fpsdk::common::math::Clamp (const T val, const T min, const T max)
 Clamp value in range.
 
template<typename T >
constexpr T fpsdk::common::math::DegToRad (T degrees)
 Convert degrees to radians.
 
template<typename T >
constexpr T fpsdk::common::math::RadToDeg (T radians)
 Convert radians to degrees.
 
double fpsdk::common::math::RoundToFracDigits (const double value, const int digits)
 Round to desired number of fractional digits (of precision)
 
Bit manipulation functions

Examples:

uint8_t mask = 0;
SetBits(mask, Bit(0) | Bit(1) | Bit(7)); // mask is now 0x83
const bool bit_7_is_set = CheckBits(mask, Bit(7)); // true
void SetBits(T &mask, const T bits)
Sets the bits.
Definition math.hpp:176
constexpr T Bit(const size_t bit)
Return a number with the given bit set to 1 (i.e. 2^bit)
Definition math.hpp:118
template<typename T >
constexpr T fpsdk::common::math::Bit (const size_t bit)
 Return a number with the given bit set to 1 (i.e. 2^bit)
 
template<typename T >
constexpr bool fpsdk::common::math::CheckBitsAll (const T mask, const T bits)
 Checks if all bits are set.
 
template<typename T >
constexpr bool fpsdk::common::math::CheckBitsAny (const T mask, const T bits)
 Checks if any bits are set.
 
template<typename T >
constexpr T fpsdk::common::math::GetBits (const T value, const T mask)
 Extracts bits.
 
template<typename T >
void fpsdk::common::math::SetBits (T &mask, const T bits)
 Sets the bits.
 
template<typename T >
void fpsdk::common::math::ClearBits (T &mask, const T bits)
 Clears the bits.
 
template<typename T >
void fpsdk::common::math::ToggleBits (T &mask, const T bits)
 Toggles the bits.
 

Detailed Description

Fixposition SDK: Math utilities.

* ___    ___
* \  \  /  /
*  \  \/  /   Copyright (c) Fixposition AG (www.fixposition.com) and contributors
*  /  /\  \   License: see the LICENSE file
* /__/  \__\
* 

Definition in file math.hpp.