1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Add length and length_squared to Vector2i/3i

This commit is contained in:
Aaron Franke
2021-11-29 11:13:31 -06:00
parent 1dee3e0cc7
commit 2c52f16464
6 changed files with 53 additions and 0 deletions

View File

@@ -210,6 +210,14 @@ Vector2i Vector2i::clamp(const Vector2i &p_min, const Vector2i &p_max) const {
CLAMP(y, p_min.y, p_max.y));
}
int64_t Vector2i::length_squared() const {
return x * (int64_t)x + y * (int64_t)y;
}
double Vector2i::length() const {
return Math::sqrt((double)length_squared());
}
Vector2i Vector2i::operator+(const Vector2i &p_v) const {
return Vector2i(x + p_v.x, y + p_v.y);
}