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

Function vm_Orthogonalize

vecmat/vector.cpp:554–572  ·  view source on GitHub ↗

Ensure that a matrix is orthogonal

Source from the content-addressed store, hash-verified

552
553// Ensure that a matrix is orthogonal
554void vm_Orthogonalize(matrix *m) {
555 // Normalize forward vector
556 if (vm_NormalizeVector(&m->fvec) == 0) {
557 Int3(); // forward vec should not be zero-length
558 return;
559 }
560
561 // Generate right vector from forward and up vectors
562 m->rvec = m->uvec ^ m->fvec;
563
564 // Normaize new right vector
565 if (vm_NormalizeVector(&m->rvec) == 0) {
566 vm_VectorToMatrix(m, &m->fvec, NULL, NULL); // error, so generate from forward vector only
567 return;
568 }
569
570 // Recompute up vector, in case it wasn't entirely perpendiclar
571 m->uvec = m->fvec ^ m->rvec;
572}
573
574// do the math for vm_VectorToMatrix()
575void DoVectorToMatrix(matrix *m, vector *fvec, vector *uvec, vector *rvec) {

Callers 15

PhysicsDoSimRotFunction · 0.50
HObjectPlaceFunction · 0.50
RotateObjectFunction · 0.50
ComputePlacedRoomMatrixFunction · 0.50
get_axis_valueMethod · 0.50
get_axis_valueMethod · 0.50
OnDrawMethod · 0.50
ReadObjectFunction · 0.50
TCSSSCallbackFunction · 0.50
DrawStarsFunction · 0.50
DrawSkyFunction · 0.50

Calls 2

vm_NormalizeVectorFunction · 0.85
vm_VectorToMatrixFunction · 0.70

Tested by

no test coverage detected