From 634ec9e2ef24d7ca0af33ffe1eb3bcc0d42178ea Mon Sep 17 00:00:00 2001 From: prdeving Date: Wed, 2 Apr 2025 19:19:04 +0200 Subject: [PATCH 1/3] [ADD] fixed point operations pow and log ALSO fixed point test cases --- libopenage/util/fixed_point.h | 18 ++++++++++++++++++ libopenage/util/fixed_point_test.cpp | 6 ++++++ 2 files changed, 24 insertions(+) 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); From 6f8c1c7ba3f1793b509e8912e03ca5cdca2d65fc Mon Sep 17 00:00:00 2001 From: prdeving Date: Wed, 2 Apr 2025 19:26:40 +0200 Subject: [PATCH 2/3] [ADD] contributor list --- copying.md | 1 + 1 file changed, 1 insertion(+) diff --git a/copying.md b/copying.md index 9d8f6703e1..efe2713fdf 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. From bece579a2a7250b3d61a6b127b16a12986488373 Mon Sep 17 00:00:00 2001 From: PRDeving Date: Fri, 4 Apr 2025 00:42:01 +0200 Subject: [PATCH 3/3] Update copying.md Co-authored-by: Christoph Heine <6852422+heinezen@users.noreply.github.com> --- copying.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copying.md b/copying.md index efe2713fdf..2c0f9f989a 100644 --- a/copying.md +++ b/copying.md @@ -165,7 +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 | +| 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.