Returns the normalized vector - one that has the same direction but unit length.
| 40 | |
| 41 | /// Returns the normalized vector - one that has the same direction but unit length. |
| 42 | inline Vector2 normalize(bool allowZero = false) const { |
| 43 | if (double len = length()) |
| 44 | return Vector2(x/len, y/len); |
| 45 | return Vector2(0, !allowZero); |
| 46 | } |
| 47 | |
| 48 | /// Returns a vector with the same length that is orthogonal to this one. |
| 49 | inline Vector2 getOrthogonal(bool polarity = true) const { |