View on GitHub



A module containing a numeric 2D vector type.

struct Vector2(T) if (isNumeric!T);
Utility template struct for manipulating 2-dimensional vectors

Vector2 is a simple class that defines a mathematical vector with two coordinates (x and y).

It can be used to represent anything that has two dimensions: a size, a point, a velocity, etc.

The template parameter T is the type of the coordinates. It can be any type that supports arithmetic operations (+, -, /, *) and comparisons (==, !=), for example int or float.

T x;
X coordinate of the vector

T y;
Y coordinate of the vector

this(T X, T Y);
Construct the vector from its coordinates

T X X coordinate.
T Y Y coordinate.

this(E)(Vector2!E otherVector);
Construct the vector from another type of vector

Vector2!E otherVector Vector to convert.