Return one unit orthogonal vector of the current vector
| 44 | |
| 45 | // Return one unit orthogonal vector of the current vector |
| 46 | Vector3 Vector3::getOneUnitOrthogonalVector() const { |
| 47 | |
| 48 | assert(length() > MACHINE_EPSILON); |
| 49 | |
| 50 | // Get the minimum element of the vector |
| 51 | Vector3 vectorAbs(std::abs(x), std::abs(y), std::abs(z)); |
| 52 | int minElement = vectorAbs.getMinAxis(); |
| 53 | |
| 54 | if (minElement == 0) { |
| 55 | return Vector3(0.0, -z, y) / std::sqrt(y*y + z*z); |
| 56 | } |
| 57 | else if (minElement == 1) { |
| 58 | return Vector3(-z, 0.0, x) / std::sqrt(x*x + z*z); |
| 59 | } |
| 60 | else { |
| 61 | return Vector3(-y, x, 0.0) / std::sqrt(x*x + y*y); |
| 62 | } |
| 63 | |
| 64 | } |
nothing calls this directly
no test coverage detected