这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions copying.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ _the openage authors_ are:
| Munawar Hafiz | munahaf | munawar dawt hafiz à gmail dawt com |
| Md Ashhar | ashhar | mdashhar01 à gmail dawt com |
| Fábio Barkoski | fabiobarkoski | fabiobarkoskii à gmail dawt com |
| Astitva Kamble | askastitva | astitvakamble5 à 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.
Expand Down
9 changes: 9 additions & 0 deletions libopenage/util/fixed_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ class FixedPoint {
constexpr double sqrt() {
return std::sqrt(this->to_double());
}

constexpr double atan2(const FixedPoint &n) {
return std::atan2(this->to_double(), n.to_double());
}
};


Expand Down Expand Up @@ -481,6 +485,11 @@ constexpr double sqrt(openage::util::FixedPoint<I, F> n) {
return n.sqrt();
}

template <typename I, unsigned F>
constexpr double atan2(openage::util::FixedPoint<I, F> x, openage::util::FixedPoint<I, F> y) {
return x.atan2(y);
}

template <typename I, unsigned F>
constexpr openage::util::FixedPoint<I, F> min(openage::util::FixedPoint<I, F> x, openage::util::FixedPoint<I, F> y) {
return openage::util::FixedPoint<I, F>::from_raw_value(
Expand Down
3 changes: 2 additions & 1 deletion libopenage/util/fixed_point_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016-2018 the openage authors. See copying.md for legal info.
// Copyright 2016-2023 the openage authors. See copying.md for legal info.

#include "fixed_point.h"

Expand Down Expand Up @@ -58,6 +58,7 @@ void fixed_point() {
TESTEQUALS_FLOAT((e * 10).to_double(), 108.3 * 10, 1e-7);
TESTEQUALS_FLOAT((e / 10).to_double(), 108.3 / 10, 1e-7);
TESTEQUALS_FLOAT(std::sqrt(e), sqrt(108.3), 1e-7);
TESTEQUALS_FLOAT(std::atan2(e, f), atan2(108.3, -12.4), 1e-7);
TESTEQUALS_FLOAT(std::abs(-e).to_double(), 108.3, 1e-7);
TESTEQUALS_FLOAT(std::hypot(e, f), hypot(108.3, -12.4), 1e-7);
TESTEQUALS_FLOAT(std::min(e, f), -12.4, 1e-7);
Expand Down