diff --git a/doomsday/libdeng2/include/de/core/vector.h b/doomsday/libdeng2/include/de/core/vector.h index be3e0d9f15..7cf9f47af3 100644 --- a/doomsday/libdeng2/include/de/core/vector.h +++ b/doomsday/libdeng2/include/de/core/vector.h @@ -169,6 +169,9 @@ class Vector2 ddouble length() const { return std::sqrt(ddouble(x*x + y*y)); } + void setLength(ddouble len) { + *this = *this / length() * len; + } Vector2 normalize() const { ddouble const len = length(); if(len != 0) { @@ -353,6 +356,9 @@ class Vector3 : public Vector2 inline ddouble length() const { return std::sqrt(lengthSquared()); } + void setLength(ddouble len) { + *this = *this / length() * len; + } ddouble lengthSquared() const { return Vector2::x*Vector2::x + Vector2::y*Vector2::y + z*z; }