Skip to content

Vec2

A 2-Dimensional vector consisting of x and y fields.

Constructor

Vec2()

Returns a new Vec2 object with x and y fields set to 0.

Vec2(x, y)

Returns a new Vec2 object with set x and y fields.

Fields

x

X-coordinate.

y

Y-coordinate.

Methods

Normalize()

Normalizes the values.

Length()

Returns the length of the current vector.

LengthSqr()

Returns the squared length of the vector (x² + y²).

DistTo(Vec2)

Returns the distance to the given vector.

DistToSqr(Vec2)

Returns the squared distance of 2 vectors.

Dot(Vec2)

Calculates the dot product of the two vectors.