diff --git a/copying.md b/copying.md index 9d8f6703e1..2c0f9f989a 100644 --- a/copying.md +++ b/copying.md @@ -165,6 +165,7 @@ _the openage authors_ are: | Ana Trias-Labellarte | anatriaslabella | ana dawt triaslabella à ufl dawt edu | | Eelco Empting | Eeelco | me à eelco dawt de | | Jordan Sutton | jsutCodes | jsutcodes à gmail dawt com | +| Pablo Roizo | PRDeving | pablo dawt deving à gmail dawt com | If you're a first-time committer, add yourself to the above list. This is not just for legal reasons, but also to keep an overview of all those nicknames. diff --git a/libopenage/util/fixed_point.h b/libopenage/util/fixed_point.h index 2d6a7eb084..b0c2f7852d 100644 --- a/libopenage/util/fixed_point.h +++ b/libopenage/util/fixed_point.h @@ -465,6 +465,14 @@ class FixedPoint { constexpr double tan() { return std::tan(this->to_double()); } + + constexpr double pow(const FixedPoint &exponent) { + return std::pow(this->to_double(), exponent.to_double()); + } + + constexpr double log() { + return std::log(this->to_double()); + } }; @@ -597,6 +605,16 @@ constexpr double tan(openage::util::FixedPoint n) { return n.tan(); } +template +constexpr double pow(openage::util::FixedPoint n, openage::util::FixedPoint exponent) { + return n.pow(exponent); +} + +template +constexpr double log(openage::util::FixedPoint n) { + return n.log(); +} + template constexpr openage::util::FixedPoint min(openage::util::FixedPoint x, openage::util::FixedPoint y) { return openage::util::FixedPoint::from_raw_value( diff --git a/libopenage/util/fixed_point_test.cpp b/libopenage/util/fixed_point_test.cpp index 21fd788259..4dc8ed9ec1 100644 --- a/libopenage/util/fixed_point_test.cpp +++ b/libopenage/util/fixed_point_test.cpp @@ -48,6 +48,7 @@ void fixed_point() { TestType e(120.7); TestType f(-12.4); + TestType g(3.0); e += f; TESTEQUALS_FLOAT(e.to_double(), 108.3, 1e-7); @@ -64,6 +65,11 @@ void fixed_point() { TESTEQUALS_FLOAT(std::hypot(e, f), hypot(108.3, -12.4), 1e-7); TESTEQUALS_FLOAT(std::min(e, f), -12.4, 1e-7); TESTEQUALS_FLOAT(std::max(e, f), 108.3, 1e-7); + TESTEQUALS_FLOAT(std::sin(e), e.sin(), 1e-7); + TESTEQUALS_FLOAT(std::cos(e), e.cos(), 1e-7); + TESTEQUALS_FLOAT(std::tan(e), e.tan(), 1e-7); + TESTEQUALS_FLOAT(std::pow(e, g), e.pow(g), 1e-7); + TESTEQUALS_FLOAT(std::log(e), e.log(), 1e-7); TESTEQUALS_FLOAT(TestType::min_value().to_double(), -2147483648.0, 1e-7); TESTEQUALS_FLOAT(TestType::max_value().to_double(), 2147483648.0, 1e-7);