You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
745 B

4 years ago
  1. #pragma
  2. class Vector3 {
  3. public:
  4. union {
  5. float v[3];
  6. struct {
  7. float x, y, z;
  8. };
  9. };
  10. Vector3() {
  11. x = 0.0f;
  12. y = 0.0f;
  13. z = 0.0f;
  14. };
  15. Vector3(float x, float y, float z) {
  16. this->x = x;
  17. this->y = y;
  18. this->z = z;
  19. }
  20. Vector3(const Vector3& v) {
  21. x = v.x;
  22. y = v.y;
  23. z = v.z;
  24. }
  25. Vector3 operator+(const Vector3& v) const;
  26. Vector3 operator*(const Vector3& v) const;
  27. void operator*=(float scale);
  28. Vector3 operator/(float scale) const;
  29. void operator/=(float scale);
  30. void operator=(const Vector3& v);
  31. float operator[](int index) {
  32. return v[index];
  33. }
  34. void Normalize();
  35. float Magnitude();
  36. };
  37. Vector3 operator*(float f, const Vector3& v);
  38. float Dot(const Vector3& l, const Vector3& r);