Class: Vec2

Vec2(x, y)

A 2D Vector of floating point numbers.

Constructor

new Vec2(x, y)

Parameters:
Name Type Description
x number

The x coordinate

y number

The y coordinate

Source:

Methods

(static) add(u, v) → {Vec2}

Adds two vectors.

Parameters:
Name Type Description
u Vec2

The first vector.

v Vec2

The second vector.

Source:
Returns:

The sum of the two vectors.

Type
Vec2

(static) neg(v) → {Vec2}

Negates a vector by negating both components.

Parameters:
Name Type Description
v Vec2

The vector to negate.

Source:
Returns:

The negated vector.

Type
Vec2

(static) scale(v, s) → {Vec2}

Scales a vector by a scaling factor.

Parameters:
Name Type Description
v Vec2

The vector to scale.

s number

The scaling factor.

Source:
Returns:

The scaled vector.

Type
Vec2

(static) sub(u, v) → {Vec2}

Subtracts the second vector from the first vector.

Parameters:
Name Type Description
u Vec2

The vector to subtract from.

v Vec2

The vector to subtract.

Source:
Returns:

The difference of the two vectors.

Type
Vec2