vector4.vala 783 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2012-2016 Daniele Bartolini and individual contributors.
  3. * License: https://github.com/taylor001/crown/blob/master/LICENSE-GPLv2
  4. */
  5. using Gee;
  6. namespace Crown
  7. {
  8. public struct Vector4
  9. {
  10. public double x;
  11. public double y;
  12. public double z;
  13. public double w;
  14. public Vector4(double x, double y, double z, double w)
  15. {
  16. this.x = x;
  17. this.y = y;
  18. this.z = z;
  19. this.w = w;
  20. }
  21. public Vector4.from_array(ArrayList<Value?> arr)
  22. {
  23. this.x = (double)arr[0];
  24. this.y = (double)arr[1];
  25. this.z = (double)arr[2];
  26. this.w = (double)arr[3];
  27. }
  28. public string to_string()
  29. {
  30. return "%f, %f, %f, %f".printf(x, y, z, w);
  31. }
  32. }
  33. const Vector4 VECTOR4_ZERO = { 0.0, 0.0, 0.0, 0.0 };
  34. const Vector4 VECTOR4_ONE = { 1.0, 1.0, 1.0, 1.0 };
  35. }