PageRenderTime 30ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/src/sharpr.c

https://github.com/mattbornski/spice
C | 164 lines | 10 code | 56 blank | 98 comment | 0 complexity | 927ac07f3ab17447a6e65f207bdce601 MD5 | raw file
  1. /* sharpr.f -- translated by f2c (version 19980913).
  2. You must link the resulting object file with the libraries:
  3. -lf2c -lm (in that order)
  4. */
  5. #include "f2c.h"
  6. /* $Procedure SHARPR ( Sharpen a rotation ) */
  7. /* Subroutine */ int sharpr_(doublereal *rot)
  8. {
  9. extern /* Subroutine */ int ucrss_(doublereal *, doublereal *, doublereal
  10. *), vhatip_(doublereal *);
  11. /* $ Abstract */
  12. /* Given a matrix that is "nearly" a rotation, adjust the columns */
  13. /* (from left to right in the usual printed presentation of a matrix) */
  14. /* so that the columns are numerically unit length and orthogonal. */
  15. /* $ Disclaimer */
  16. /* THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE */
  17. /* CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. */
  18. /* GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE */
  19. /* ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE */
  20. /* PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" */
  21. /* TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY */
  22. /* WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A */
  23. /* PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC */
  24. /* SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE */
  25. /* SOFTWARE AND RELATED MATERIALS, HOWEVER USED. */
  26. /* IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA */
  27. /* BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT */
  28. /* LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, */
  29. /* INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, */
  30. /* REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE */
  31. /* REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. */
  32. /* RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF */
  33. /* THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY */
  34. /* CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE */
  35. /* ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. */
  36. /* $ Required_Reading */
  37. /* None. */
  38. /* $ Keywords */
  39. /* MATRIX */
  40. /* $ Declarations */
  41. /* $ Brief_I/O */
  42. /* VARIABLE I/O DESCRIPTION */
  43. /* -------- --- -------------------------------------------------- */
  44. /* ROT I/O The rotation matrix to be sharpened. */
  45. /* $ Detailed_Input */
  46. /* ROT a 3x3 matrix that is nearly a rotation matrix. */
  47. /* $ Detailed_Output */
  48. /* ROT the input after sharpening the columns. */
  49. /* $ Parameters */
  50. /* None. */
  51. /* $ Files */
  52. /* None. */
  53. /* $ Exceptions */
  54. /* Error free. */
  55. /* 1) This routine is not meant to be used on singular or near- */
  56. /* singular matrices (in other words, matrices with determinant */
  57. /* close to zero). */
  58. /* If the input matrix is singular, the output matrix may not */
  59. /* be a rotation matrix. In any case, the results should be */
  60. /* considered unreliable in this case. */
  61. /* No error handling is done for invalid input matrices. */
  62. /* $ Particulars */
  63. /* This routine "sharpens" the orthogonality of a potential */
  64. /* rotation matrix. It is intended for use in those situations */
  65. /* in which you have a rotation matrix that may be derived */
  66. /* from single precision inputs or that may have experienced */
  67. /* round off errors in its construction. */
  68. /* $ Examples */
  69. /* Suppose that you have a rotation matrix that needs to be */
  70. /* converted to a quaternion. The SPICE matrix to quaternion */
  71. /* conversion routine M2Q performs error checks on the input */
  72. /* matrix and signals an error if it does not meet the checks */
  73. /* for a quaternion. By calling this routine you can ensure that */
  74. /* your rotation matrix (provided it's non-singular) will pass */
  75. /* the restrictions imposed by M2Q. */
  76. /* CALL SHARPR ( ROT ) */
  77. /* CALL M2Q ( ROT, Q ) */
  78. /* $ Restrictions */
  79. /* See the Exceptions section above. */
  80. /* $ Author_and_Institution */
  81. /* N.J. Bachman (JPL) */
  82. /* W.L. Taber (JPL) */
  83. /* $ Literature_References */
  84. /* None. */
  85. /* $ Version */
  86. /* - SPICELIB Version 1.1.0, 13-OCT-2005 (NJB) */
  87. /* Updated to remove non-standard use of duplicate arguments */
  88. /* in VHAT call. Some header updates were made. */
  89. /* - SPICELIB Version 1.0.0, 16-SEP-1999 (WLT) */
  90. /* -& */
  91. /* $ Index_Entries */
  92. /* Sharpen the orhogonality of the columns of a rotation */
  93. /* -& */
  94. /* $ Revisions */
  95. /* - SPICELIB Version 1.1.0, 13-OCT-2005 (NJB) */
  96. /* Updated to remove non-standard use of duplicate arguments */
  97. /* in VHAT call. Some header updates were made. */
  98. /* -& */
  99. /* Unitize the first column of the rotation. */
  100. vhatip_(rot);
  101. /* Unitize the third column of the rotation and make it */
  102. /* orthogonal to the first two columns. */
  103. ucrss_(rot, &rot[3], &rot[6]);
  104. /* Unitize the second column of the rotation and make it */
  105. /* orthogonal to the first and third columns. */
  106. ucrss_(&rot[6], rot, &rot[3]);
  107. return 0;
  108. } /* sharpr_ */