// 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 #include "Angle.h" template <> AngleOf::AngleOf(int angle) { signed long long_angle = (signed short)angle * 65536; this->value = (signed short)(long_angle / 360); } template <> AngleOf::AngleOf(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); } // template <> // AngleOf::operator float() const { // float f = ((this->value * 180) / 32768.0F); // return f; // } template <> float AngleOf::ToFloat() const { float f = ((this->value * 180) / 32768.0F); return f; } template <> AngleOf AngleOf::operator-() const { AngleOf angle = AngleOf(); angle.value = -this->value; return angle; } template <> AngleOf AngleOf::operator-( const AngleOf& a) const { AngleOf angle = AngleOf(); angle.value = this->value - a.value; return angle; } template <> AngleOf AngleOf::operator+( const AngleOf& a) const { AngleOf angle = AngleOf(); angle.value = this->value + a.value; return angle; } // Not correct!!! just for syntactical compilation ATM template <> AngleOf AngleOf::CosineRuleSide( float a, float b, AngleOf gamma) { float a2 = a * a; float b2 = b * b; float d = a2 + b2 - 2 * a * b * cosf(gamma.ToFloat() * Passer::LinearAlgebra::Deg2Rad); // Catch edge cases where float inacuracies lead tot nans if (d < 0) return 0.0f; float c = sqrtf(d); return c; } // Not correct!!! just for syntactical compilation ATM template <> AngleOf AngleOf::CosineRuleAngle(float a, float b, float c) { float a2 = a * a; float b2 = b * b; float c2 = c * c; float d = (a2 + b2 - c2) / (2 * a * b); // Catch edge cases where float inacuracies lead tot nans if (d >= 1) return 0.0f; if (d <= -1) return 180.0f; float gamma = acosf(d) * Passer::LinearAlgebra::Rad2Deg; return gamma; } */