2024-03-15 10:46:30 +01:00

23 lines
408 B
C

#include "AngleUsing.h"
#include "Angle.h"
#include <math.h>
typedef AngleUsing<signed char> Angle8;
Angle8::AngleUsing(float angle) {
if (!isfinite(angle)) {
value = 0;
return;
}
// map float [-180..180) to integer [-128..127]
float f = angle / 360.0F;
this->value = (signed char)(f * 256.0F);
}
float Angle8::ToFloat() const {
float f = (this->value * 180) / 128.0F;
return f;
}