From 092346d82b9e3a7e3f957e7d239db09fc4b4a0c4 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sun, 4 Aug 2019 18:50:28 -0700 Subject: Add Vector2/3 sign and posmod functions, misc additions Also make the docs more consistent, add Axis enum to Vector2, add > and >=. and C# also gets % and an override for vector-vector mod. --- core/math/vector2.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/math/vector2.cpp') diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index 779a28be66..972bccc0ac 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -98,6 +98,11 @@ real_t Vector2::cross(const Vector2 &p_other) const { return x * p_other.y - y * p_other.x; } +Vector2 Vector2::sign() const { + + return Vector2(SGN(x), SGN(y)); +} + Vector2 Vector2::floor() const { return Vector2(Math::floor(x), Math::floor(y)); @@ -121,6 +126,14 @@ Vector2 Vector2::rotated(real_t p_by) const { return v; } +Vector2 Vector2::posmod(const real_t p_mod) const { + return Vector2(Math::fposmod(x, p_mod), Math::fposmod(y, p_mod)); +} + +Vector2 Vector2::posmodv(const Vector2 &p_modv) const { + return Vector2(Math::fposmod(x, p_modv.x), Math::fposmod(y, p_modv.y)); +} + Vector2 Vector2::project(const Vector2 &p_b) const { return p_b * (dot(p_b) / p_b.length_squared()); } -- cgit v1.2.3