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

Function vm_VectorAngleToMatrix

vecmat/vector.cpp:533–551  ·  view source on GitHub ↗

Computes a matrix from a vector and and angle of rotation around that vector Parameters: m - filled in with the computed matrix v - the forward vector of the new matrix a - the angle of rotation around the forward vector

Source from the content-addressed store, hash-verified

531// v - the forward vector of the new matrix
532// a - the angle of rotation around the forward vector
533void vm_VectorAngleToMatrix(matrix *m, vector *v, angle a) {
534 float sinb, cosb, sinp, cosp, sinh, cosh;
535
536 sinb = FixSin(a);
537 cosb = FixCos(a);
538
539 sinp = -v->y;
540 cosp = sqrt(1.0 - (sinp * sinp));
541
542 if (cosp != 0.0) {
543 sinh = v->x / cosp;
544 cosh = v->z / cosp;
545 } else {
546 sinh = 0;
547 cosh = 1.0;
548 }
549
550 vm_SinCosToMatrix(m, sinp, cosp, sinb, cosb, sinh, cosh);
551}
552
553// Ensure that a matrix is orthogonal
554void vm_Orthogonalize(matrix *m) {

Callers 3

ComputePlacedRoomMatrixFunction · 0.50
AddScorchFunction · 0.50

Calls 3

vm_SinCosToMatrixFunction · 0.70
FixSinFunction · 0.50
FixCosFunction · 0.50

Tested by

no test coverage detected