1#pragma once
2
3#include <nn/util/MathTypes.h>
4#include <nn/util/detail/util_ArithmeticImpl.h>
5
6namespace nn::util {
7
8inline AngleIndex RadianToAngleIndex(float radian) {
9 return static_cast<int64_t>(radian * (detail::AngleIndexHalfRound / detail::FloatPi));
10}
11
12inline float DegreeToRadian(float degree) {
13 return degree * (detail::FloatPi / detail::FloatDegree180);
14}
15
16inline float SinTable(AngleIndex angleIndex) {
17 uint32_t sampleTableIndex = (angleIndex >> 24) & 0xFF;
18 float rest = static_cast<float>(angleIndex & 0xFFFFFF) / 0x1000000;
19 const detail::SinCosSample* table = &detail::SinCosSampleTable[sampleTableIndex];
20 return table->sinValue + table->sinDelta * rest;
21}
22
23inline float CosTable(AngleIndex angleIndex) {
24 uint32_t sampleTableIndex = (angleIndex >> 24) & 0xFF;
25 const detail::SinCosSample* table = &detail::SinCosSampleTable[sampleTableIndex];
26 float rest = static_cast<float>(angleIndex & 0xFFFFFF) / 0x1000000;
27 return table->cosValue + table->cosDelta * rest;
28}
29
30} // namespace nn::util