Return the corresponding unit vector
| 31 | |
| 32 | // Return the corresponding unit vector |
| 33 | Vector2 Vector2::getUnit() const { |
| 34 | decimal lengthVector = length(); |
| 35 | |
| 36 | if (lengthVector < MACHINE_EPSILON) { |
| 37 | return *this; |
| 38 | } |
| 39 | |
| 40 | // Compute and return the unit vector |
| 41 | decimal lengthInv = decimal(1.0) / lengthVector; |
| 42 | return Vector2(x * lengthInv, y * lengthInv); |
| 43 | } |
| 44 | |
| 45 | // Return one unit orthogonal vector of the current vector |
| 46 | Vector2 Vector2::getOneUnitOrthogonalVector() const { |
no test coverage detected