using System;
namespace Engine.Core;
/// 
/// Represents a two-dimensional integer vector.
/// 
/// X position of the .
/// Y position of the .
/// 
/// Initializes a new instance of the  struct with the specified positions.
/// 
[System.Diagnostics.DebuggerDisplay("{ToString(),nq}")]
public readonly struct Vector2DInt(int x, int y) : IEquatable
{
    /// 
    /// The X coordinate of the .
    /// 
    public readonly int X = x;
    /// 
    /// The Y coordinate of the .
    /// 
    public readonly int Y = y;
    /// 
    /// The magnitude (length) of the .
    /// 
    public float Magnitude => Length(this);
    /// 
    /// The squared magnitude (length) of the .
    /// 
    public float MagnitudeSquared => LengthSquared(this);
    /// 
    /// Gets a  with the direction reversed.
    /// 
    public readonly Vector2DInt Reversed => -this;
    /// 
    /// Represents the unit  pointing upwards.
    /// 
    public readonly static Vector2DInt Up = new(0, 1);
    /// 
    /// Represents the unit  pointing downwards.
    /// 
    public readonly static Vector2DInt Down = new(0, -1);
    /// 
    /// Represents the unit  pointing leftwards.
    /// 
    public readonly static Vector2DInt Left = new(-1, 0);
    /// 
    /// Represents the unit  pointing rightwards.
    /// 
    public readonly static Vector2DInt Right = new(1, 0);
    /// 
    /// Represents the zero .
    /// 
    public readonly static Vector2DInt Zero = new(0, 0);
    /// 
    /// Represents the  with both components equal to 1.
    /// 
    public readonly static Vector2DInt One = new(1, 1);
    public static Vector2DInt operator -(Vector2DInt vector) => new(0 - vector.X, 0 - vector.Y);
    public static Vector2DInt operator +(Vector2DInt left, Vector2DInt right) => new(left.X + right.X, left.Y + right.Y);
    public static Vector2DInt operator -(Vector2DInt left, Vector2DInt right) => new(left.X - right.X, left.Y - right.Y);
    public static bool operator ==(Vector2DInt left, Vector2DInt right) => left.X == right.X && left.Y == right.Y;
    public static bool operator !=(Vector2DInt left, Vector2DInt right) => left.X != right.X || left.Y != right.Y;
    public static implicit operator Vector2DInt(Vector2D vector) => new(vector.X.RoundToInt(), vector.Y.RoundToInt());
    public static implicit operator Vector2DInt(Vector3DInt vector) => new(vector.X, vector.Y);
    /// 
    /// Calculates the length of the .
    /// 
    /// The .
    /// The length of the .
    public static float Length(Vector2DInt vector) => Engine.Core.Math.Sqrt(LengthSquared(vector));
    /// 
    /// Calculates the squared length of the .
    /// 
    /// The .
    /// The squared length of the .
    public static float LengthSquared(Vector2DInt vector) => vector.X * vector.X + vector.Y * vector.Y;
    /// 
    /// Calculates the distance between two s.
    /// 
    /// The start .
    /// The end .
    /// The distance between the two s.
    public static float Distance(Vector2DInt from, Vector2DInt to) => Length(FromTo(from, to));
    /// 
    /// Inverts the direction of the .
    /// 
    /// The .
    /// The inverted .
    public static Vector2DInt Invert(Vector2DInt vector) => -vector;
    /// 
    /// Adds two s.
    /// 
    /// The first .
    /// The second .
    /// The sum of the two s.
    public static Vector2DInt Add(Vector2DInt left, Vector2DInt right) => left + right;
    /// 
    /// Subtracts one  from another.
    /// 
    /// The  to subtract from.
    /// The  to subtract.
    /// The result of subtracting the second  from the first.
    public static Vector2DInt Subtract(Vector2DInt left, Vector2DInt right) => left - right;
    /// 
    /// Calculates the absolute value of each component of the vector.
    /// 
    /// The .
    /// The  with each component's absolute value.
    public static Vector2DInt Abs(Vector2DInt vector) => new(Engine.Core.Math.Abs(vector.X), Engine.Core.Math.Abs(vector.Y));
    /// 
    /// Calculates the  from one point to another.
    /// 
    /// The starting point.
    /// The ending point.
    /// The  from the starting point to the ending point.
    public static Vector2DInt FromTo(Vector2DInt from, Vector2DInt to) => to - from;
    /// 
    /// Scales a  by another  component-wise.
    /// 
    /// The  to scale.
    /// The  containing the scaling factors for each component.
    /// The scaled .
    public static Vector2DInt Scale(Vector2DInt vector, Vector2DInt scale) => new(vector.X * scale.X, vector.Y * scale.Y);
    /// 
    /// Calculates a perpendicular  to the given .
    /// 
    /// The input .
    /// A  perpendicular to the input .
    public static Vector2DInt Perpendicular(Vector2DInt vector) => new(-vector.Y, vector.X);
    /// 
    /// Returns the component-wise minimum of two s.
    /// 
    /// The first .
    /// The second .
    /// The  containing the minimum components from both input s.
    public static Vector2DInt Min(Vector2DInt left, Vector2DInt right) => new((left.X < right.X) ? left.X : right.X, (left.Y < right.Y) ? left.Y : right.Y);
    /// 
    /// Returns the component-wise maximum of two s.
    /// 
    /// The first .
    /// The second .
    /// The  containing the maximum components from both input s.
    public static Vector2DInt Max(Vector2DInt left, Vector2DInt right) => new((left.X > right.X) ? left.X : right.X, (left.Y > right.Y) ? left.Y : right.Y);
    /// 
    /// Clamps each component of a  between the corresponding component of two other s.
    /// 
    /// The  to clamp.
    /// The  representing the minimum values for each component.
    /// The  representing the maximum values for each component.
    /// A  with each component clamped between the corresponding components of the min and max s.
    public static Vector2DInt Clamp(Vector2DInt vector, Vector2DInt min, Vector2DInt max) => new(Engine.Core.Math.Clamp(vector.X, min.X, max.X), Engine.Core.Math.Clamp(vector.Y, min.Y, max.Y));
    /// 
    /// Calculates the cross product of two s.
    /// 
    /// The first .
    /// The second .
    /// The cross product of the two s.
    public static int Cross(Vector2DInt left, Vector2DInt right) => left.X * right.Y - left.Y * right.X;
    /// 
    /// Calculates the dot product of two s.
    /// 
    /// The first .
    /// The second .
    /// The dot product of the two s.
    public static int Dot(Vector2DInt left, Vector2DInt right) => left.X * right.X + left.Y * right.Y;
    /// 
    /// Determines whether the specified object is equal to the current .
    /// 
    /// The object to compare with the current .
    ///  if the specified object is equal to the current ; otherwise, .
    public override bool Equals(object? obj) => obj is Vector2DInt vector2DInt && this == vector2DInt;
    public bool Equals(Vector2DInt other) => this == other;
    /// 
    /// Generates a hash code for the .
    /// 
    /// A hash code for the .
    public override int GetHashCode() => System.HashCode.Combine(X, Y);
    /// 
    /// Converts the  to its string representation.
    /// 
    /// A string representation of the .
    public override string ToString() => $"{nameof(Vector2DInt)}({X}, {Y})";
}
/// 
/// Provides extension methods for  type.
/// 
public static class Vector2DIntExtensions
{
    /// 
    public static float Length(this Vector2DInt vector) => Vector2DInt.Length(vector);
    /// 
    public static float Distance(this Vector2DInt from, Vector2DInt to) => Vector2DInt.Distance(from, to);
    /// 
    public static Vector2DInt Add(this Vector2DInt vector, Vector2DInt vectorToAdd) => Vector2DInt.Add(vector, vectorToAdd);
    /// 
    public static Vector2DInt Subtract(this Vector2DInt vector, Vector2DInt vectorToSubtract) => Vector2DInt.Subtract(vector, vectorToSubtract);
    /// 
    public static Vector2DInt Abs(this Vector2DInt vector) => Vector2DInt.Abs(vector);
    /// 
    public static Vector2DInt FromTo(this Vector2DInt from, Vector2DInt to) => Vector2DInt.FromTo(from, to);
    /// 
    public static Vector2DInt Scale(this Vector2DInt vector, Vector2DInt scale) => Vector2DInt.Scale(vector, scale);
    /// 
    public static Vector2DInt Perpendicular(this Vector2DInt vector) => Vector2DInt.Perpendicular(vector);
    /// 
    public static Vector2DInt Min(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Min(left, right);
    /// 
    public static Vector2DInt Max(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Max(left, right);
    /// 
    public static Vector2DInt Clamp(this Vector2DInt vector, Vector2DInt min, Vector2DInt max) => Vector2DInt.Clamp(vector, min, max);
    /// 
    public static int Cross(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Cross(left, right);
    /// 
    public static float AngleBetween(this Vector2D left, Vector2D right) => Vector2D.Angle(left, right);
    /// 
    public static int Dot(this Vector2DInt left, Vector2DInt right) => Vector2DInt.Dot(left, right);
}