libxr
1.0
Want to be the best embedded framework
|
浮点数编码器,将浮点值映射到定长无符号整数。 A generic float encoder mapping a float value to N-bit unsigned integer. More...
#include <float_encoder.hpp>
Public Member Functions | |
FloatEncoder (Scalar min, Scalar max) | |
构造函数,设置映射区间 [min, max]。 Constructor specifying the float range [min, max]. | |
uint32_t | Encode (Scalar value) const |
编码:将浮点数映射为无符号整数。 Encodes a float to unsigned integer in range [0, 2^Bits - 1]. | |
Scalar | Decode (uint32_t encoded) const |
解码:将无符号整数还原为浮点值。 Decodes an unsigned integer to float. | |
Static Public Member Functions | |
static constexpr uint32_t | MaxInt () |
获取最大可编码的整数值。 Returns the maximum encodable unsigned integer. | |
Private Attributes | |
Scalar | min_ |
浮点区间最小值 | |
Scalar | max_ |
浮点区间最大值 | |
Scalar | range_ |
区间范围(max - min) | |
浮点数编码器,将浮点值映射到定长无符号整数。 A generic float encoder mapping a float value to N-bit unsigned integer.
用于将连续区间 [min, max] 映射到整数区间 [0, 2^bits - 1], 可用于 IMU 数据、传感器值、CAN 打包等场景。
Bits | 使用的整数位数,例如 21 表示使用 21-bit 无符号整数。 |
Scalar | 浮点数类型,默认为 float。 |
Definition at line 21 of file float_encoder.hpp.
|
inline |
构造函数,设置映射区间 [min, max]。 Constructor specifying the float range [min, max].
min | 最小浮点值。Minimum float value. |
max | 最大浮点值。Maximum float value. |
Definition at line 39 of file float_encoder.hpp.
|
inline |
解码:将无符号整数还原为浮点值。 Decodes an unsigned integer to float.
encoded | 编码后的整数。Encoded unsigned integer. |
Definition at line 62 of file float_encoder.hpp.
|
inline |
编码:将浮点数映射为无符号整数。 Encodes a float to unsigned integer in range [0, 2^Bits - 1].
value | 输入的浮点数值。Input float value. |
Definition at line 48 of file float_encoder.hpp.
|
inlinestaticconstexpr |
获取最大可编码的整数值。 Returns the maximum encodable unsigned integer.
Definition at line 30 of file float_encoder.hpp.
|
private |
浮点区间最大值
Definition at line 70 of file float_encoder.hpp.
|
private |
浮点区间最小值
Definition at line 69 of file float_encoder.hpp.
|
private |
区间范围(max - min)
Definition at line 71 of file float_encoder.hpp.