Vector of two Float values x and y.

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

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

trace( b.length ); // 5

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

Operations:

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

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:Float

staticy:Float

staticread onlylength:Float

Gets the current vector-length

staticread onlycopy:Vec2

A new vector instance with the same values.

Static methods

staticinlineisEqual(this:Vec2Impl, v:Vec2):Bool

Compare this to another vector of equality.

Parameters:

v

Vec2

staticinlinecopyFrom(this:Vec2Impl, v:Vec2):Vec2

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

staticinlinenegate(this:Vec2Impl):Vec2

Negates the values of this vector and returns its reference.

staticinlinenormalize(this:Vec2Impl):Vec2

Normalizes the values of this vector and returns its reference.

staticinlineadd(this:Vec2Impl, v:Vec2):Vec2

Adds the values of another vector to this vector.

staticinlinesubtract(this:Vec2Impl, v:Vec2):Vec2

Subtracts the values of another vector from this vector.

staticinlinemul(this:Vec2Impl, f:Float):Vec2

Multiplicates the values of this vector by a Float

staticinlinediv(this:Vec2Impl, f:Float):Vec2

Divides the values of this vector by a Float