lvec2_ops_src.I 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Filename: lvec2_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 * LVecBase2
  20. // Description:
  21. ////////////////////////////////////////////////////////////////////
  22. INLINE_LINMATH FLOATNAME(LVecBase2)
  23. operator * (FLOATTYPE scalar, const FLOATNAME(LVecBase2) &a) {
  24. return a * scalar;
  25. }
  26. ////////////////////////////////////////////////////////////////////
  27. // Function: scalar * LPoint2
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE_LINMATH FLOATNAME(LPoint2)
  31. operator * (FLOATTYPE scalar, const FLOATNAME(LPoint2) &a) {
  32. return a * scalar;
  33. }
  34. ////////////////////////////////////////////////////////////////////
  35. // Function: scalar * LVector2
  36. // Description:
  37. ////////////////////////////////////////////////////////////////////
  38. INLINE_LINMATH FLOATNAME(LVector2)
  39. operator * (FLOATTYPE scalar, const FLOATNAME(LVector2) &a) {
  40. return a * scalar;
  41. }
  42. ////////////////////////////////////////////////////////////////////
  43. // Function: dot product of LVecBase2
  44. // Description:
  45. ////////////////////////////////////////////////////////////////////
  46. INLINE_LINMATH FLOATTYPE
  47. dot(const FLOATNAME(LVecBase2) &a, const FLOATNAME(LVecBase2) &b) {
  48. return a.dot(b);
  49. }
  50. ////////////////////////////////////////////////////////////////////
  51. // Function: length of a vector
  52. // Description:
  53. ////////////////////////////////////////////////////////////////////
  54. INLINE_LINMATH FLOATTYPE
  55. length(const FLOATNAME(LVector2) &a) {
  56. return a.length();
  57. }
  58. ////////////////////////////////////////////////////////////////////
  59. // Function: normalize
  60. // Description: Returns a normalized vector from the given vector.
  61. ////////////////////////////////////////////////////////////////////
  62. INLINE_LINMATH FLOATNAME(LVector2)
  63. normalize(const FLOATNAME(LVector2) &v) {
  64. FLOATNAME(LVector2) v1 = v;
  65. v1.normalize();
  66. return v1;
  67. }