Vector3D.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef VECTOR3D_H
  2. #define VECTOR3D_H
  3. #ifndef M_PI
  4. #define M_PI 3.14159265358979323846
  5. #endif
  6. #ifndef M_PI_2
  7. #define M_PI_2 1.57079632679489661923
  8. #endif
  9. #ifndef M_PI_4
  10. #define M_PI_4 0.78539816339744830962
  11. #endif
  12. #ifndef M_1_PI
  13. #define M_1_PI 0.31830988618379067154
  14. #endif
  15. typedef struct Vector3D {
  16. float x;
  17. float y;
  18. float z;
  19. } Vector3D;
  20. void vectorSet(Vector3D* v, float x, float y, float z);
  21. void vectorSetTo(Vector3D* v1, Vector3D* v2);
  22. void vectorSetToInverse(Vector3D* v1, Vector3D* v2);
  23. void vectorSetMul(Vector3D* v1, Vector3D* v2, float f);
  24. void vectorSetAngles(Vector3D* v, float lengthAngle, float widthAngle);
  25. void vectorAdd(Vector3D* v1, Vector3D* v2);
  26. void vectorSub(Vector3D* v1, Vector3D* v2);
  27. void vectorMul(Vector3D* v1, float f);
  28. void vectorAddMul(Vector3D* v1, Vector3D* v2, float f);
  29. void vectorCross(Vector3D* v, float x, float y, float z);
  30. void vectorCrossWith(Vector3D* v1, Vector3D* v2);
  31. void vectorNormalize(Vector3D* v);
  32. float vectorLength(Vector3D* v);
  33. float vectorDot(Vector3D* v1, Vector3D* v2);
  34. float vectorDotInverse(Vector3D* v1, Vector3D* v2);
  35. #endif