Some utilities functions.
More...
#include "ame_Math.hpp"
#include <array>
#include <atomic>
#include <cassert>
#include <concepts>
#include <cstddef>
#include <type_traits>
Go to the source code of this file.
|
template<std::floating_point FloatType> |
constexpr FloatType | ame::addModulo2Pi (FloatType phase, FloatType increment) noexcept |
| Increment the phase and returns in the range of 0~2pi. More...
|
|
template<std::floating_point FloatType> |
constexpr FloatType | ame::scale (FloatType sourceValue, FloatType sourceRangeMin, FloatType sourceRangeMax, FloatType targetRangeMin, FloatType targetRangeMax) |
| Map values to an output range. More...
|
|
template<typename... Ts> |
constexpr std::array< std::byte, sizeof...(Ts)> | ame::makeBytes (Ts &&... args) noexcept |
| Generate a std::array<std::byte, N> More...
|
|
Some utilities functions.
- Author
- Akiyuki Okayasu (akiyu.nosp@m.ki.o.nosp@m.kayas.nosp@m.u@gm.nosp@m.ail.c.nosp@m.om)
- Copyright
- Copyright (c) 2021 - Akiyuki Okayasu
AME is released under the MIT license.
◆ addModulo2Pi()
template<std::floating_point FloatType>
constexpr FloatType ame::addModulo2Pi |
( |
FloatType |
phase, |
|
|
FloatType |
increment |
|
) |
| |
|
constexprnoexcept |
Increment the phase and returns in the range of 0~2pi.
- Template Parameters
-
- Parameters
-
phase | |
increment | Amount to add to phase |
- Returns
- [0, 2pi]
◆ makeBytes()
template<typename... Ts>
constexpr std::array< std::byte, sizeof...(Ts)> ame::makeBytes |
( |
Ts &&... |
args | ) |
|
|
constexprnoexcept |
Generate a std::array<std::byte, N>
std::array<std::byte, 2> b = {0x00, 0xFF}; will cause an error due to implicit casting from int to std::byte. std::array<std::byte, 2> b = {std::byte{0x00}, std::byte{0xFF}}; does not cause an error, but it is tedious, so make_bytes(0x00, 0xFF) can be used to generate it.
constexpr std::array<std::byte, 2> arr =
makeBytes(0x00, 0xFF);
constexpr std::array< std::byte, sizeof...(Ts)> makeBytes(Ts &&... args) noexcept
Generate a std::array<std::byte, N>
Definition: ame_Util.hpp:380
- Template Parameters
-
Ts | Integer types. It must be able to be cast to std::byte. |
- Parameters
-
args | Integers to convert to std::byte array |
- Returns
- constexpr std::array<std::byte, sizeof...(Ts)>
◆ scale()
template<std::floating_point FloatType>
constexpr FloatType ame::scale |
( |
FloatType |
sourceValue, |
|
|
FloatType |
sourceRangeMin, |
|
|
FloatType |
sourceRangeMax, |
|
|
FloatType |
targetRangeMin, |
|
|
FloatType |
targetRangeMax |
|
) |
| |
|
constexpr |
Map values to an output range.
- Template Parameters
-
- Parameters
-
sourceValue | input value |
sourceRangeMin | input range min |
sourceRangeMax | input range Max |
targetRangeMin | output range min |
targetRangeMax | output range Max |
- Returns
- scaled value