// This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0.If a copy of the MPL was not distributed with this // file, You can obtain one at https ://mozilla.org/MPL/2.0/. #include #include "Angle.h" template <> AngleOf::AngleOf(int angle) { signed short short_angle = (signed char)angle * 256; this->value = (signed char)(short_angle / 360); } template <> AngleOf::AngleOf(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); } // template <> // AngleOf::operator float() const { // float f = (this->value * 180) / 128.0F; // return f; // } template <> float AngleOf::ToFloat() const { float f = (this->value * 180) / 128.0F; return f; }