(v: [f32; 3])
| 273 | } |
| 274 | |
| 275 | fn normalise(v: [f32; 3]) -> [f32; 3] { |
| 276 | let len_sq = v[0] * v[0] + v[1] * v[1] + v[2] * v[2]; |
| 277 | if len_sq < 1e-10 { |
| 278 | // Default to +Y — a horizontal mirror like a calm lake. |
| 279 | return [0.0, 1.0, 0.0]; |
| 280 | } |
| 281 | let inv = 1.0 / len_sq.sqrt(); |
| 282 | [v[0] * inv, v[1] * inv, v[2] * inv] |
| 283 | } |
| 284 | |
| 285 | // ===================================================================== |
| 286 | // Tests |
no outgoing calls
no test coverage detected