MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / vm_VectorNormalizeFast

Function vm_VectorNormalizeFast

scripts/osiris_vector.h:497–512  ·  view source on GitHub ↗

Normalize a vector using an approximation of the magnitude Returns: the magnitude before normalization

Source from the content-addressed store, hash-verified

495// Normalize a vector using an approximation of the magnitude
496// Returns: the magnitude before normalization
497float 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

Callers 3

qObjCanSeeObjFunction · 0.70
qObjCanSeeObjAdvancedFunction · 0.70
vm_GetNormalizedDirFastFunction · 0.70

Calls 1

vm_GetMagnitudeFastFunction · 0.70

Tested by

no test coverage detected