diff options
| author | Aaron Franke <arnfranke@yahoo.com> | 2019-08-04 18:50:28 -0700 |
|---|---|---|
| committer | Aaron Franke <arnfranke@yahoo.com> | 2019-08-17 18:31:55 -0400 |
| commit | 092346d82b9e3a7e3f957e7d239db09fc4b4a0c4 (patch) | |
| tree | 01b0c261f4f0169b25ed971b838dc3272f80ea16 /core/math/vector2.cpp | |
| parent | cc9f2a2d8bf36e7244e7291ad7fdb32a3e3f2ef2 (diff) | |
| download | redot-engine-092346d82b9e3a7e3f957e7d239db09fc4b4a0c4.tar.gz | |
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.
Diffstat (limited to 'core/math/vector2.cpp')
| -rw-r--r-- | core/math/vector2.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
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()); } |
