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:
parent
cc9f2a2d8b
commit
092346d82b
8 changed files with 237 additions and 14 deletions
|
|
@ -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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue