! Returns a normalized version of this vector. The length of the returned vector is equal to 1. If the vector has both entries set to zero, this method returns the vector unmodified. \see normalize, length, lengthSquared */
| 174 | \see normalize, length, lengthSquared |
| 175 | */ |
| 176 | QCPVector2D QCPVector2D::normalized() const |
| 177 | { |
| 178 | if (mX == 0.0 && mY == 0.0) return *this; |
| 179 | const double lenInv = 1.0/length(); |
| 180 | return QCPVector2D(mX*lenInv, mY*lenInv); |
| 181 | } |
| 182 | |
| 183 | /*! \overload |
| 184 |
no test coverage detected