Vector3.cs 773 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2012-2015 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE
  4. */
  5. using System;
  6. namespace Crown
  7. {
  8. public struct Vector3
  9. {
  10. public Vector3(float x, float y, float z)
  11. {
  12. this.x = x;
  13. this.y = y;
  14. this.z = z;
  15. }
  16. public static Vector3 operator+(Vector3 a, Vector3 b)
  17. {
  18. return new Vector3(a.x + b.x, a.y + b.y, a.z + b.z);
  19. }
  20. public static Vector3 operator-(Vector3 a, Vector3 b)
  21. {
  22. return new Vector3(a.x - b.x, a.y - b.y, a.z - b.z);
  23. }
  24. public static Vector3 operator*(Vector3 a, float k)
  25. {
  26. return new Vector3(a.x * k, a.y * k, a.z * k);
  27. }
  28. public static Vector3 operator*(float k, Vector3 a)
  29. {
  30. return a * k;
  31. }
  32. public float x, y, z;
  33. }
  34. }