# Vec2

A vector with 2 components: x and y. This can represent a point in 2D space, a directional vector, or any other sort of value with 2 dimensions to it!

## Instance Fields and Properties

float x Vector components.
float y Vector components.

## Instance Methods

Vec2 A basic constructor, just copies the values in!
Angle Returns the counter-clockwise degrees from [1,0]. Resulting value is between 0 and 360. Vector does not need to be normalized.
Normalize Turns this vector into a normalized vector (vector with a length of 1) from the current vector. Will not work properly if the vector has a length of zero.
Normalized Creates a normalized vector (vector with a length of 1) from the current vector. Will not work properly if the vector has a length of zero.

## Static Fields and Properties

float Magnitude Magnitude is the length of the vector! Or the distance from the origin to this point. Uses Math.Sqrt, so it’s not dirt cheap or anything.
float MagnitudeSq This is the squared magnitude of the vector! It skips the Sqrt call, and just gives you the squared version for speedy calculations that can work with it squared.
Vec2 One A Vec2 with all components at one, same as new Vec2(1,1).
Vec2 Zero A Vec2 with all components at zero, same as new Vec2(0,0).

## Static Methods

AngleBetween Calculates a signed angle between two vectors! Sign will be positive if B is counter-clockwise (left) of A, and negative if B is clockwise (right) of A. Vectors do not need to be normalized.
Distance Calculates the distance between two points in space! Make sure they’re in the same coordinate space! Uses a Sqrt, so it’s not blazing fast, prefer DistanceSq when possible.
DistanceSq Calculates the distance between two points in space, but leaves them squared! Make sure they’re in the same coordinate space! This is a fast function :)
Dot The dot product is an extremely useful operation! One major use is to determine how similar two vectors are. If the vectors are Unit vectors (magnitude/length of 1), then the result will be 1 if the vectors are the same, -1 if they’re opposite, and a gradient in-between with 0 being perpendicular. See Freya Holmer’s excellent visualization of this concept