Vec.cs 655 B

1234567891011121314151617181920212223242526272829303132333435
  1. namespace Day24;
  2. public readonly record struct Vec
  3. {
  4. public static Vec Zero { get; } = new Vec(0, 0);
  5. public long X { get; }
  6. public long Y { get; }
  7. public Vec(long x, long y)
  8. {
  9. X = x;
  10. Y = y;
  11. }
  12. public Vec Add(Vec other)
  13. {
  14. return new Vec(X + other.X, Y + other.Y);
  15. }
  16. public Vec Subtract(Vec other)
  17. {
  18. return new Vec(X - other.X, Y - other.Y);
  19. }
  20. public Vec Multiply(long f)
  21. {
  22. return new Vec(f * X, f * Y);
  23. }
  24. public (double X, double Y) Multiply(double f)
  25. {
  26. return (f * X, f * Y);
  27. }
  28. }