Clone of UAS2 @ https://github.com/drudgedance/uas2

cPhysics.h 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * This file is part of UAS2.
  3. *
  4. * UAS2 is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * UAS2 is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. * You should have received a copy of the GNU General Public License
  14. * along with UASv1; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. /**
  18. * @file cPhysics.h
  19. */
  20. #if !defined(AFX_CPHYSICS_H__87BF30D9_6373_47F7_AAC7_56024CA96079__INCLUDED_)
  21. #define AFX_CPHYSICS_H__87BF30D9_6373_47F7_AAC7_56024CA96079__INCLUDED_
  22. #if _MSC_VER > 1000
  23. #pragma once
  24. #endif // _MSC_VER > 1000
  25. #include "uas.h"
  26. ///////////////////////////////////////
  27. // Math Functions - Quaternion
  28. ///////////////////////////////////////
  29. struct quaternion
  30. {
  31. float x, y, z, w;
  32. };
  33. struct vector
  34. {
  35. float x, y, z;
  36. };
  37. ///////////////////////////////////////
  38. class cPhysics
  39. {
  40. public:
  41. cPhysics();
  42. virtual ~cPhysics();
  43. static float length ( quaternion quat );
  44. static quaternion normalize ( quaternion quat );
  45. static quaternion conjugate ( quaternion quat );
  46. static quaternion mult ( quaternion A, quaternion B );
  47. static void Rotate ( float Angle, float x, float y, float z, vector& View );
  48. static float GetRange ( cLocation usrLoc, cLocation tarLoc );
  49. static float Get3DRange ( cLocation usrLoc, cLocation tarLoc );
  50. static cVelocity GetTargetVelocity ( cLocation usrLoc, cLocation tarLoc );
  51. static cLocation VelocityMove ( cLocation usrLoc, cVelocity tarVel, float flSpeed );
  52. static float GetLineDistance ( cLocation OldLoc, cLocation NewLoc, cLocation TarLoc );
  53. static float Get3DLineDistance ( cLocation OldLoc, cLocation NewLoc, cLocation TarLoc );
  54. static float GetHeadingTarget ( cLocation usrLoc, cLocation tarLoc );
  55. static float GetAvatarHeading ( cLocation usrLoc );
  56. static float GetHeadingDifference( float flUserHeading, float flTargetHeading );
  57. static float GetLandZ ( cLocation usrLoc );
  58. };
  59. #endif // !defined(AFX_CPHYSICS_H__87BF30D9_6373_47F7_AAC7_56024CA96079__INCLUDED_)