Normalize a vector using an approximation of the magnitude Returns: the magnitude before normalization
| 495 | // Normalize a vector using an approximation of the magnitude |
| 496 | // Returns: the magnitude before normalization |
| 497 | float vm_VectorNormalizeFast(vector *a) { |
| 498 | float mag; |
| 499 | |
| 500 | mag = vm_GetMagnitudeFast(a); |
| 501 | |
| 502 | if (mag == 0.0) { |
| 503 | a->x = a->y = a->z = 0.0; |
| 504 | return 0; |
| 505 | } |
| 506 | |
| 507 | a->x = (a->x / mag); |
| 508 | a->y = (a->y / mag); |
| 509 | a->z = (a->z / mag); |
| 510 | |
| 511 | return mag; |
| 512 | } |
| 513 | |
| 514 | // Computes the distance from a point to a plane. |
| 515 | // Parms: checkp - the point to check |
no test coverage detected