diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 18:40:11 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 18:40:11 +0100 |
commit | ef3f5b0845ba127c0bfcda8c2fce37013fef3878 (patch) | |
tree | e5690ff875a662ee7603844e858d82428d973a78 /src/crepe/api/Vector2.hpp | |
parent | 424da5eb1500d90389d939cd0b3e6e75d729578d (diff) | |
parent | 2ad15f3efab481659543a1c03cd70a36fd297538 (diff) |
Merge branch 'master' of github.com:lonkaars/crepe into jaro/game
Diffstat (limited to 'src/crepe/api/Vector2.hpp')
-rw-r--r-- | src/crepe/api/Vector2.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/crepe/api/Vector2.hpp b/src/crepe/api/Vector2.hpp index e195760..30441d2 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); +} |