Skip to content

Commit 1c3f0ea

Browse files
authored
Merge pull request #1753 from anatriaslabella/Open-source-contribution
Added sin, cos, and tan operations to fixed point implementation
2 parents cec174d + 81b0443 commit 1c3f0ea

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

copying.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ _the openage authors_ are:
162162
| Michael Lynch | mtlynch | git à mtlynch dawt io |
163163
| Ngô Xuân Minh | | xminh dawt ngo dawt 00 à gmail dawt com |
164164
| Haytham Tang | haytham918 | yunxuant à umich dawt edu |
165+
| Ana Trias-Labellarte | anatriaslabella | ana dawt triaslabella à ufl dawt edu |
165166

166167
If you're a first-time committer, add yourself to the above list. This is not
167168
just for legal reasons, but also to keep an overview of all those nicknames.

libopenage/util/fixed_point.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2015-2024 the openage authors. See copying.md for legal info.
1+
// Copyright 2015-2025 the openage authors. See copying.md for legal info.
22

33
#pragma once
44

@@ -451,6 +451,18 @@ class FixedPoint {
451451
constexpr double atan2(const FixedPoint &n) {
452452
return std::atan2(this->to_double(), n.to_double());
453453
}
454+
455+
constexpr double sin() {
456+
return std::sin(this->to_double());
457+
}
458+
459+
constexpr double cos() {
460+
return std::cos(this->to_double());
461+
}
462+
463+
constexpr double tan() {
464+
return std::tan(this->to_double());
465+
}
454466
};
455467

456468

@@ -567,6 +579,21 @@ constexpr double atan2(openage::util::FixedPoint<I, F> x, openage::util::FixedPo
567579
return x.atan2(y);
568580
}
569581

582+
template <typename I, unsigned F>
583+
constexpr double sin(openage::util::FixedPoint<I, F> n) {
584+
return n.sin();
585+
}
586+
587+
template <typename I, unsigned F>
588+
constexpr double cos(openage::util::FixedPoint<I, F> n) {
589+
return n.cos();
590+
}
591+
592+
template <typename I, unsigned F>
593+
constexpr double tan(openage::util::FixedPoint<I, F> n) {
594+
return n.tan();
595+
}
596+
570597
template <typename I, unsigned F>
571598
constexpr openage::util::FixedPoint<I, F> min(openage::util::FixedPoint<I, F> x, openage::util::FixedPoint<I, F> y) {
572599
return openage::util::FixedPoint<I, F>::from_raw_value(

0 commit comments

Comments
 (0)