BabylonVector3.cs 1007 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. namespace BabylonExport.Entities
  3. {
  4. public class BabylonVector3
  5. {
  6. public float X { get; set; }
  7. public float Y { get; set; }
  8. public float Z { get; set; }
  9. public float[] ToArray()
  10. {
  11. return new [] {X, Y, Z};
  12. }
  13. public float Length()
  14. {
  15. return (float)Math.Sqrt(X * X + Y * Y + Z * Z);
  16. }
  17. public static BabylonVector3 operator +(BabylonVector3 a, BabylonVector3 b)
  18. {
  19. return new BabylonVector3 {X = a.X + b.X, Y = a.Y + b.Y, Z = a.Z + b.Z};
  20. }
  21. public static BabylonVector3 operator -(BabylonVector3 a, BabylonVector3 b)
  22. {
  23. return new BabylonVector3 { X = a.X - b.X, Y = a.Y - b.Y, Z = a.Z - b.Z };
  24. }
  25. public static BabylonVector3 operator /(BabylonVector3 a, float b)
  26. {
  27. return new BabylonVector3 { X = a.X / b, Y = a.Y / b, Z = a.Z / b };
  28. }
  29. }
  30. }