| 167 | } |
| 168 | |
| 169 | inline void CoordinateSystem(const Vector &v1, Vector *v2, Vector *v3) { |
| 170 | if (fabsf(v1.x) > fabsf(v1.y)) { |
| 171 | float invLen = 1.f / sqrtf(v1.x * v1.x + v1.z * v1.z); |
| 172 | *v2 = Vector(-v1.z * invLen, 0.f, v1.x * invLen); |
| 173 | } else { |
| 174 | float invLen = 1.f / sqrtf(v1.y * v1.y + v1.z * v1.z); |
| 175 | *v2 = Vector(0.f, v1.z * invLen, -v1.y * invLen); |
| 176 | } |
| 177 | *v3 = Cross(v1, *v2); |
| 178 | } |
| 179 | |
| 180 | inline Vector SphericalDirection(float sintheta, float costheta, float phi) { |
| 181 | return Vector(sintheta * cosf(phi), sintheta * sinf(phi), costheta); |
no test coverage detected