| 277 | } |
| 278 | |
| 279 | inline bool Quadratic(float A, float B, float C, float *t0, float *t1) { |
| 280 | // Find quadratic discriminant |
| 281 | float discrim = B * B - 4.f * A * C; |
| 282 | if (discrim < 0.f) |
| 283 | return false; |
| 284 | float rootDiscrim = sqrtf(discrim); |
| 285 | // Compute quadratic _t_ values |
| 286 | float q; |
| 287 | if (B < 0) |
| 288 | q = -.5f * (B - rootDiscrim); |
| 289 | else |
| 290 | q = -.5f * (B + rootDiscrim); |
| 291 | *t0 = q / A; |
| 292 | *t1 = C / q; |
| 293 | if (*t0 > *t1) |
| 294 | Swap(*t0, *t1); |
| 295 | return true; |
| 296 | } |
| 297 | |
| 298 | inline float SmoothStep(float min, float max, float value) { |
| 299 | float v = Clamp((value - min) / (max - min), 0.f, 1.f); |