Vector of two Int values x and y.

// constructing
var a = new Vec2i(1, 2);
var b:Vec2i = { x:3, y:4};
var c:Vec2i = [ 1, 2 ];

// access values
trace(a.x); // 1
a.y = 42;

trace( b.length ); // 9

.length calculates the current vector-length (same by casting the vector to a Float).

Operations:

+, - between two vectors results in a new Vec2i, while * (dot product) results in a Float.
* and / between a Vec2i and a Float results in a new (stretched or compressed) Vec2i.

Comparing vectors:

>, <, >=, <= results into comparing the lengths of the vectors.
a.isEqual(b) can be used to compare two vectors a and b for value-equality.

Static variables

staticx:Int

staticy:Int

staticread onlylength:Float

Gets the current vector-length

staticread onlycopy:Vec2i

A new vector instance with the same values.

Static methods

staticinlineisEqual(this:Vec2iImpl, v:Vec2i):Bool

Compare this to another vector of equality.

Parameters:

v

Vec2i

staticinlinecopyFrom(this:Vec2iImpl, v:Vec2i):Vec2i

Copyes the values of another inside this vector and returns its reference.

staticinlinenegate(this:Vec2iImpl):Vec2i

Negates the values of this vector and returns its reference.

staticinlineadd(this:Vec2iImpl, v:Vec2i):Vec2i

Adds the values of another vector to this vector.

staticinlinesubtract(this:Vec2iImpl, v:Vec2i):Vec2i

Subtracts the values of another vector from this vector.

staticinlinemul(this:Vec2iImpl, f:Float):Vec2i

Multiplicates the values of this vector by a Float

staticinlinediv(this:Vec2iImpl, f:Float):Vec2i

Divides the values of this vector by a Float