mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
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.
This commit is contained in:
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user