Normalize a vector using an approximation of the magnitude Returns: the magnitude before normalization
| 451 | // Normalize a vector using an approximation of the magnitude |
| 452 | // Returns: the magnitude before normalization |
| 453 | float vm_NormalizeVectorFast(vector *a) { |
| 454 | float mag; |
| 455 | |
| 456 | mag = vm_GetMagnitudeFast(a); |
| 457 | |
| 458 | if (mag == 0.0) { |
| 459 | a->x = a->y = a->z = 0.0; |
| 460 | return 0; |
| 461 | } |
| 462 | |
| 463 | a->x = (a->x / mag); |
| 464 | a->y = (a->y / mag); |
| 465 | a->z = (a->z / mag); |
| 466 | |
| 467 | return mag; |
| 468 | } |
| 469 | |
| 470 | // Computes the distance from a point to a plane. |
| 471 | // Parms: checkp - the point to check |
no test coverage detected