[DEV] add safeNormalize in vec2
This commit is contained in:
parent
63c9ff74c2
commit
45c4fbb98d
@ -257,6 +257,17 @@ namespace etk {
|
||||
*this /= length();
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Normalize this vector
|
||||
* x^2 + y^2 + z^2 = 1
|
||||
*/
|
||||
Vector2D<T>& safeNormalize() {
|
||||
T tmp = length();
|
||||
if (tmp != 0) {
|
||||
*this /= length();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
/**
|
||||
* @brief Return a normalized version of this vector
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user