lvec3_ops_src.I 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Filename: lvec3_ops_src.I
  2. // Created by: drose (08Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: scalar * LVecBase3
  20. // Description:
  21. ////////////////////////////////////////////////////////////////////
  22. INLINE_LINMATH FLOATNAME(LVecBase3)
  23. operator * (FLOATTYPE scalar, const FLOATNAME(LVecBase3) &a) {
  24. return a * scalar;
  25. }
  26. ////////////////////////////////////////////////////////////////////
  27. // Function: scalar * LPoint3
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE_LINMATH FLOATNAME(LPoint3)
  31. operator * (FLOATTYPE scalar, const FLOATNAME(LPoint3) &a) {
  32. return a * scalar;
  33. }
  34. ////////////////////////////////////////////////////////////////////
  35. // Function: scalar * LVector3
  36. // Description:
  37. ////////////////////////////////////////////////////////////////////
  38. INLINE_LINMATH FLOATNAME(LVector3)
  39. operator * (FLOATTYPE scalar, const FLOATNAME(LVector3) &a) {
  40. return a * scalar;
  41. }
  42. ////////////////////////////////////////////////////////////////////
  43. // Function: dot product of LVecBase3
  44. // Description:
  45. ////////////////////////////////////////////////////////////////////
  46. INLINE_LINMATH FLOATTYPE
  47. dot(const FLOATNAME(LVecBase3) &a, const FLOATNAME(LVecBase3) &b) {
  48. return a.dot(b);
  49. }
  50. ////////////////////////////////////////////////////////////////////
  51. // Function: cross product of LVecBase3
  52. // Description:
  53. ////////////////////////////////////////////////////////////////////
  54. INLINE_LINMATH FLOATNAME(LVecBase3)
  55. cross(const FLOATNAME(LVecBase3) &a, const FLOATNAME(LVecBase3) &b) {
  56. return a.cross(b);
  57. }
  58. ////////////////////////////////////////////////////////////////////
  59. // Function: cross product of LVector3
  60. // Description:
  61. ////////////////////////////////////////////////////////////////////
  62. INLINE_LINMATH FLOATNAME(LVector3)
  63. cross(const FLOATNAME(LVector3) &a, const FLOATNAME(LVector3) &b) {
  64. return FLOATNAME(LVector3)(a.cross(b));
  65. }
  66. ////////////////////////////////////////////////////////////////////
  67. // Function: length of a vector
  68. // Description:
  69. ////////////////////////////////////////////////////////////////////
  70. INLINE_LINMATH FLOATTYPE
  71. length(const FLOATNAME(LVector3) &a) {
  72. return a.length();
  73. }
  74. ////////////////////////////////////////////////////////////////////
  75. // Function: normalize
  76. // Description: Returns a normalized vector from the given vector.
  77. ////////////////////////////////////////////////////////////////////
  78. INLINE_LINMATH FLOATNAME(LVector3)
  79. normalize(const FLOATNAME(LVector3) &v) {
  80. FLOATNAME(LVector3) v1 = v;
  81. v1.normalize();
  82. return v1;
  83. }