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
| 531 | // v - the forward vector of the new matrix |
| 532 | // a - the angle of rotation around the forward vector |
| 533 | void 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 |
| 554 | void vm_Orthogonalize(matrix *m) { |
no test coverage detected