LinearAlgebra-cpp/Angle16.h
2024-03-15 11:23:49 +01:00

22 lines
444 B
C

#include "AngleUsing.h"
#include "Angle.h"
#include <math.h>
typedef AngleUsing<signed short> Angle16;
AngleUsing<signed short>::AngleUsing(float angle) {
if (!isfinite(angle)) {
value = 0;
return;
}
// map float [-180..180) to integer [-32768..32767]
this->value = (signed short)((angle / 360.0F) * 65536.0F);
}
float AngleUsing<signed short>::ToFloat() const {
float f = ((this->value * 180) / 32768.0F);
return f;
}