Vector4.pkg 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. $#include "Vector4.h"
  2. /// Four-dimensional vector.
  3. class Vector4
  4. {
  5. public:
  6. /// Construct undefined.
  7. Vector4();
  8. /// Copy-construct from another vector.
  9. Vector4(const Vector4& vector);
  10. /// Construct from a 3-dimensional vector and the W coordinate.
  11. Vector4(const Vector3& vector, float w);
  12. /// Construct from coordinates.
  13. Vector4(float x, float y, float z, float w);
  14. /// Test for equality with another vector without epsilon.
  15. bool operator == (const Vector4& rhs) const;
  16. /// Add a vector.
  17. Vector4 operator + (const Vector4& rhs) const;
  18. /// Return negation.
  19. Vector4 operator - () const;
  20. /// Subtract a vector.
  21. Vector4 operator - (const Vector4& rhs) const;
  22. /// Multiply with a scalar.
  23. Vector4 operator * (float rhs) const;
  24. /// Multiply with a vector.
  25. Vector4 operator * (const Vector4& rhs) const;
  26. /// Divide by a scalar.
  27. Vector4 operator / (float rhs) const;
  28. /// Divide by a vector.
  29. Vector4 operator / (const Vector4& rhs) const;
  30. /// Calculate dot product.
  31. float DotProduct(const Vector4& rhs) const;
  32. /// Calculate absolute dot product.
  33. float AbsDotProduct(const Vector4& rhs) const;
  34. /// Return absolute vector.
  35. Vector4 Abs() const;
  36. /// Linear interpolation with another vector.
  37. Vector4 Lerp(const Vector4& rhs, float t) const;
  38. /// Test for equality with another vector with epsilon.
  39. bool Equals(const Vector4& rhs) const;
  40. /// X coordinate.
  41. float x_ @ x;
  42. /// Y coordinate.
  43. float y_ @ y;
  44. /// Z coordinate.
  45. float z_ @ z;
  46. /// W coordinate.
  47. float w_ @ w;
  48. /// Zero vector.
  49. static const Vector4 ZERO;
  50. /// (1,1,1) vector.
  51. static const Vector4 ONE;
  52. };