diff options
| author | Thomas Herzog <therzog@mail.de> | 2018-08-16 12:52:38 +0200 |
|---|---|---|
| committer | Thomas Herzog <therzog@mail.de> | 2018-08-16 12:52:38 +0200 |
| commit | 037f4638aba99981393edd247057f851e80db489 (patch) | |
| tree | 70075682e7bd0666b69e4f78d9fac5292715de7e /core/math/vector2.cpp | |
| parent | af93842f937270f5e25cd7270fba1cde18cd21c9 (diff) | |
| download | redot-engine-037f4638aba99981393edd247057f851e80db489.tar.gz | |
add project method to Vector2/3
Diffstat (limited to 'core/math/vector2.cpp')
| -rw-r--r-- | core/math/vector2.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index 441e7d8907..75d9b8b311 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -121,11 +121,8 @@ Vector2 Vector2::rotated(real_t p_by) const { return v; } -Vector2 Vector2::project(const Vector2 &p_vec) const { - - Vector2 v1 = p_vec; - Vector2 v2 = *this; - return v2 * (v1.dot(v2) / v2.dot(v2)); +Vector2 Vector2::project(const Vector2 &p_b) const { + return p_b * (dot(p_b) / p_b.dot(p_b)); } Vector2 Vector2::snapped(const Vector2 &p_by) const { |
