aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Vector2.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api/Vector2.hpp')
-rw-r--r--src/crepe/api/Vector2.hpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/crepe/api/Vector2.hpp b/src/crepe/api/Vector2.hpp
index e195760..a4ce641 100644
--- a/src/crepe/api/Vector2.hpp
+++ b/src/crepe/api/Vector2.hpp
@@ -168,4 +168,14 @@ 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