extract angles from a matrix
| 678 | |
| 679 | // extract angles from a matrix |
| 680 | angvec *vm_ExtractAnglesFromMatrix(angvec *a, matrix *m) { |
| 681 | float sinh, cosh, cosp, sinb, cosb; |
| 682 | |
| 683 | // Deal with straight up or straight down |
| 684 | if (IS_ZERO(m->fvec.x) && IS_ZERO(m->fvec.z)) { |
| 685 | a->p = (m->fvec.y > 0) ? 0xc000 : 0x4000; |
| 686 | a->b = 0.0; |
| 687 | a->h = FixAtan2(m->rvec.x, -m->rvec.z); |
| 688 | return a; |
| 689 | } |
| 690 | |
| 691 | a->h = FixAtan2(m->fvec.z, m->fvec.x); |
| 692 | |
| 693 | sinh = FixSin(a->h); |
| 694 | cosh = FixCos(a->h); |
| 695 | |
| 696 | if (fabs(sinh) > fabs(cosh)) // sine is larger, so use it |
| 697 | cosp = (m->fvec.x / sinh); |
| 698 | else // cosine is larger, so use it |
| 699 | cosp = (m->fvec.z / cosh); |
| 700 | a->p = FixAtan2(cosp, -m->fvec.y); |
| 701 | |
| 702 | sinb = (m->rvec.y / cosp); |
| 703 | cosb = (m->uvec.y / cosp); |
| 704 | a->b = FixAtan2(cosb, sinb); |
| 705 | |
| 706 | return a; |
| 707 | } |
| 708 | |
| 709 | // returns the value of a determinant |
| 710 | float calc_det_value(matrix *det) { |
no test coverage detected