lorientation_src.I 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Filename: lorientation_src.I
  2. // Created by: frang, charles (23Jun00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: LOrientation::Default Constructor
  16. // Access: public
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE_LINMATH FLOATNAME(LOrientation)::
  20. FLOATNAME(LOrientation)() {
  21. }
  22. ////////////////////////////////////////////////////////////////////
  23. // Function: LOrientation::Copy Constructor
  24. // Access: public
  25. // Description:
  26. ////////////////////////////////////////////////////////////////////
  27. INLINE_LINMATH FLOATNAME(LOrientation)::
  28. FLOATNAME(LOrientation)(const FLOATNAME(LQuaternion)& c) :
  29. FLOATNAME(LQuaternion)(c) {
  30. }
  31. ////////////////////////////////////////////////////////////////////
  32. // Function: LOrientation::Constructor
  33. // Access: public
  34. // Description:
  35. ////////////////////////////////////////////////////////////////////
  36. INLINE_LINMATH FLOATNAME(LOrientation)::
  37. FLOATNAME(LOrientation)(FLOATTYPE r, FLOATTYPE i, FLOATTYPE j, FLOATTYPE k) :
  38. FLOATNAME(LQuaternion)(r, i, j, k) {
  39. }
  40. ////////////////////////////////////////////////////////////////////
  41. // Function: LOrientation::Constructor
  42. // Access: public
  43. // Description: vector + twist
  44. ////////////////////////////////////////////////////////////////////
  45. INLINE_LINMATH FLOATNAME(LOrientation)::
  46. FLOATNAME(LOrientation)(const FLOATNAME(LVector3) &point_at, float twist) {
  47. float radians = deg_2_rad(twist);
  48. float theta_over_2 = radians * FLOATCONST(0.5);
  49. float sin_to2 = sinf(theta_over_2);
  50. set_r(cosf(theta_over_2));
  51. set_i(point_at[0] * sin_to2);
  52. set_j(point_at[1] * sin_to2);
  53. set_k(point_at[2] * sin_to2);
  54. }
  55. ////////////////////////////////////////////////////////////////////
  56. // Function: LOrientation::Constructor
  57. // Access: public
  58. // Description: matrix3
  59. ////////////////////////////////////////////////////////////////////
  60. INLINE_LINMATH FLOATNAME(LOrientation)::
  61. FLOATNAME(LOrientation)(const FLOATNAME(LMatrix3) &m) {
  62. set_from_matrix(m);
  63. }
  64. ////////////////////////////////////////////////////////////////////
  65. // Function: LOrientation::Constructor
  66. // Access: public
  67. // Description: matrix4
  68. ////////////////////////////////////////////////////////////////////
  69. INLINE_LINMATH FLOATNAME(LOrientation)::
  70. FLOATNAME(LOrientation)(const FLOATNAME(LMatrix4) &m) {
  71. set_from_matrix(m);
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Function: LOrientation::operator *
  75. // Access: public
  76. // Description: Orientation * rotation = Orientation
  77. // Applies a rotation to an orientation.
  78. ////////////////////////////////////////////////////////////////////
  79. INLINE_LINMATH FLOATNAME(LOrientation) FLOATNAME(LOrientation)::
  80. operator * (const FLOATNAME(LRotation) &other) const {
  81. return multiply((FLOATNAME(LOrientation) &)other);
  82. }
  83. ////////////////////////////////////////////////////////////////////
  84. // Function: LOrientation::operator *
  85. // Access: public
  86. // Description: Orientation * Orientation
  87. // This is a meaningless operation, and will always
  88. // simply return the rhs.
  89. ////////////////////////////////////////////////////////////////////
  90. INLINE_LINMATH FLOATNAME(LOrientation) FLOATNAME(LOrientation)::
  91. operator * (const FLOATNAME(LQuaternion) &other) const {
  92. nassert_raise("LOrientation * LQuaternion is undefined; use LOrientation * LRotation or LQuaternion * LQuaternion");
  93. return multiply((FLOATNAME(LOrientation) &)other);
  94. }