summaryrefslogtreecommitdiff
path: root/core/math/vector2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/vector2.cpp')
-rw-r--r--core/math/vector2.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp
index f4259e388b..f46badd19e 100644
--- a/core/math/vector2.cpp
+++ b/core/math/vector2.cpp
@@ -119,11 +119,11 @@ Vector2 Vector2::round() const {
}
Vector2 Vector2::rotated(real_t p_by) const {
-
- Vector2 v;
- v.set_rotation(angle() + p_by);
- v *= length();
- return v;
+ real_t sine = Math::sin(p_by);
+ real_t cosi = Math::cos(p_by);
+ return Vector2(
+ x * cosi - y * sine,
+ x * sine + y * cosi);
}
Vector2 Vector2::posmod(const real_t p_mod) const {