using System;
using System.Collections.Generic;

namespace Assets.Common
{
    public class Point : ICloneable
    {
        public double x;
        public double y;
        public double Length => Math.Sqrt(x*x+y*y);
        public Point Direction => this / Length;

        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }

        public static double Dist(Point a, Point b)
        {
            return Math.Sqrt(Math.Pow(a.x - b.x, 2) + Math.Pow(a.y - b.y, 2));
        }

        public override int GetHashCode()
        {
            var hashCode = 1502939027;
            hashCode = hashCode * -1521134295 + x.GetHashCode();
            hashCode = hashCode * -1521134295 + y.GetHashCode();
            return hashCode;
        }

        public object Clone()
        {
            return new Point(x, y);
        }

        public static Point operator +(Point a, Point b) => new Point(a.x + b.x, a.y + b.y);
        public static Point operator +(Point a) => a;
        public static Point operator -(Point a, Point b) => new Point(a.x - b.x, a.y - b.y);
        public static Point operator -(Point a) => new Point(-a.x, -a.y);
        public static Point operator *(Point a, double b) => new Point(a.x * b, a.y * b);
        public static Point operator /(Point a, double b) => new Point(a.x / b, a.y / b);
    }
}