Skip to content

Commit

Permalink
libdeng2|Vector: Squared length for 2-component vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Apr 7, 2014
1 parent dd398d5 commit 82ea2f6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions doomsday/libdeng2/include/de/core/vector.h
Expand Up @@ -166,8 +166,11 @@ class Vector2
bool operator <= (Vector2 const &other) const {
return *this == other || *this < other;
}
ddouble length() const {
return std::sqrt(ddouble(x*x + y*y));
inline ddouble length() const {
return std::sqrt(lengthSquared());
}
inline ddouble lengthSquared() const {
return ddouble(x*x + y*y);
}
void setLength(ddouble len) {
*this = *this / length() * len;
Expand Down Expand Up @@ -701,6 +704,9 @@ typedef Vector4<dfloat> Vector4f; ///< 4-component vector of floating point va
typedef Vector4<ddouble> Vector4d; ///< 4-component vector of high-precision floating point values.
///@}

// Qt hash functions:
inline quint32 qHash(Vector2i const &vec) { return vec.x * vec.y + vec.x - vec.y; }

} // namespace de

#endif /* LIBDENG2_VECTOR_H */

0 comments on commit 82ea2f6

Please sign in to comment.