Vector used for 2D Math.
``````    public struct Vector2 : IEquatable<Vector2>
``````

2-element structure that can be used to represent positions in 2d-space, or any other pair of numeric values.

### Constructors

``````    public Vector2(float x, float y)
``````

Constructs a new Vector2 from the given x and y.

``````    public Vector2()
``````

### Fields

``````    public Single x
``````

X component of the vector.

``````    public Single y
``````

Y component of the vector.

### Properties

``````    public float this[] { get; set; }
``````

### Methods

``````    public Vector2 Abs()
``````

Returns a new vector with all components in absolute values (i.e. positive).

``````    public float Angle()
``````

Returns the result of atan2 when called with the Vector’s x and y as parameters (Math::atan2(x,y)).

Be aware that it therefore returns an angle oriented clockwise with regard to the (0, 1) unit vector, and not an angle oriented counter-clockwise with regard to the (1, 0) unit vector (which would be the typical trigonometric representation of the angle when calling Math::atan2(y,x)).

``````    public float AngleTo(Vector2 to)
``````

Returns the angle in radians between the two vectors.

``````    public float AngleToPoint(Vector2 to)
``````

Returns the angle in radians between the line connecting the two points and the x coordinate.

``````    public float Aspect()
``````

Returns the ratio of X to Y.

``````    public Vector2 Bounce(Vector2 n)
``````

Bounce returns the vector “bounced off” from the given plane, specified by its normal vector.

``````    public Vector2 Clamped(float length)
``````

Returns the vector with a maximum length.

``````    public Vector2 CubicInterpolate(Vector2 b, Vector2 preA, Vector2 postB, float t)
``````

Cubicly interpolates between this Vector and “b”, using “pre_a” and “post_b” as handles, and returning the result at position “t”. “t” should be a float of 0.0-1.0, a percentage of how far along the interpolation is.

``````    public float DistanceSquaredTo(Vector2 to)
``````

Returns the squared distance to vector “b”. Prefer this function over “distance_to” if you need to sort vectors or need the squared distance for some formula.

``````    public float DistanceTo(Vector2 to)
``````

Returns the distance to vector “b”.

``````    public float Dot(Vector2 with)
``````

Returns the dot product with vector “b”.

``````    public override bool Equals(object obj)
``````

``````    public bool Equals(Vector2 other)
``````

``````    public Vector2 Floor()
``````

Remove the fractional part of x and y.

``````    public override int GetHashCode()
``````

``````    public bool IsNormalized()
``````

Returns whether the vector is normalized or not.

``````    public float Length()
``````

Returns the length of the vector.

``````    public float LengthSquared()
``````

Returns the squared length of the vector. Prefer this function over “length” if you need to sort vectors or need the squared length for some formula.

``````    public Vector2 LinearInterpolate(Vector2 b, float t)
``````

Returns the result of the linear interpolation between this vector and “b”, by amount “t”. “t” should be a float of 0.0-1.0, a percentage of how far along the interpolation is.

``````    public Vector2 Normalized()
``````

Returns a normalized vector to unit length.

``````    public Vector2 Reflect(Vector2 n)
``````

Reflects the vector along the given plane, specified by its normal vector.

``````    public Vector2 Rotated(float phi)
``````

Rotates the vector by “phi” radians.

``````    public Vector2 Slide(Vector2 n)
``````

Slide returns the component of the vector along the given plane, specified by its normal vector.

``````    public Vector2 Snapped(Vector2 by)
``````

Snaps the vector to a grid with the given size.

``````    public Vector2 Tangent()
``````

Returns a perpendicular vector.

``````    public override string ToString()
``````

``````    public string ToString(string format)
``````

### Operators

``````    public static Vector2 operator +(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator /(Vector2 vec, float scale)
``````

``````    public static Vector2 operator /(Vector2 left, Vector2 right)
``````

``````    public static bool operator ==(Vector2 left, Vector2 right)
``````

``````    public static bool operator >(Vector2 left, Vector2 right)
``````

``````    public static bool operator >=(Vector2 left, Vector2 right)
``````

``````    public static bool operator !=(Vector2 left, Vector2 right)
``````

``````    public static bool operator <(Vector2 left, Vector2 right)
``````

``````    public static bool operator <=(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator *(Vector2 vec, float scale)
``````

``````    public static Vector2 operator *(float scale, Vector2 vec)
``````

``````    public static Vector2 operator *(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator -(Vector2 left, Vector2 right)
``````

``````    public static Vector2 operator -(Vector2 vec)
``````
Tags: