aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Vector2.hpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 14:39:16 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2025-01-08 14:39:16 +0100
commit18a8813645187102fc6261b8d5be1a41c8f0dae4 (patch)
tree655c5d22027fa23af3378df2d92d4051a71be2a6 /src/crepe/api/Vector2.hpp
parent0729209117a4393e66d7f5b6d83083e2d7c0694c (diff)
parentd9c67da9b8c2d8d25ef4dd2c700ddc78573d3a60 (diff)
Merge remote-tracking branch 'origin/loek/game' into niels/game
Diffstat (limited to 'src/crepe/api/Vector2.hpp')
-rw-r--r--src/crepe/api/Vector2.hpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/crepe/api/Vector2.hpp b/src/crepe/api/Vector2.hpp
index e195760..e2f96ed 100644
--- a/src/crepe/api/Vector2.hpp
+++ b/src/crepe/api/Vector2.hpp
@@ -168,4 +168,19 @@ bool Vector2<T>::is_nan() const {
return std::isnan(x) && std::isnan(y);
}
+template <class T>
+Vector2<T> Vector2<T>::rotate(float deg) const {
+ float rad = -deg / 180 * M_PI;
+ return {
+ x * std::cos(rad) - y * std::sin(rad),
+ x * std::sin(rad) + y * std::cos(rad),
+ };
+}
+
} // namespace crepe
+
+template <typename T>
+std::format_context::iterator std::formatter<crepe::Vector2<T>>::format(crepe::Vector2<T> vec, format_context & ctx) const {
+ return formatter<string>::format(std::format("{{{}, {}}}", vec.x, vec.y), ctx);
+}
+