me.Vector2d(xopt, yopt)

new Vector2d(xopt, yopt)

a generic 2D Vector Object

Parameters:
Name Type Attributes Default Description
x Number <optional>
0

x value of the vector

y Number <optional>
0

y value of the vector

Extends

Members

static x :Number

x value of the vector

static y :Number

y value of the vector

Methods

static abs() → {me.Vector2d}

Update this vector values to absolute values

Returns:
me.Vector2d -

Reference to this object for method chaining

static add(v) → {me.Vector2d}

Add the passed vector to this vector

Parameters:
Name Type Description
v me.Vector2d
Returns:
me.Vector2d -

Reference to this object for method chaining

static angle(v) → {Number}

return the angle between this vector and the passed one

Parameters:
Name Type Description
v me.Vector2d
Returns:
Number -

angle in radians

static ceil() → {me.Vector2d}

Ceil the vector values

Returns:
me.Vector2d -

new me.Vector2d

static ceilSelf() → {me.Vector2d}

Ceil this vector values

Returns:
me.Vector2d -

Reference to this object for method chaining

static clamp(low, high) → {me.Vector2d}

Clamp the vector value within the specified value range

Parameters:
Name Type Description
low Number
high Number
Returns:
me.Vector2d -

new me.Vector2d

static clampSelf(low, high) → {me.Vector2d}

Clamp this vector value within the specified value range

Parameters:
Name Type Description
low Number
high Number
Returns:
me.Vector2d -

Reference to this object for method chaining

static clone() → {me.Vector2d}

return a clone copy of this vector

Returns:
me.Vector2d -

new me.Vector2d

static copy(v) → {me.Vector2d}

Copy the x,y values of the passed vector to this one

Parameters:
Name Type Description
v me.Vector2d
Returns:
me.Vector2d -

Reference to this object for method chaining

static distance(v) → {Number}

return the distance between this vector and the passed one

Parameters:
Name Type Description
v me.Vector2d
Returns:
Number

static div(value) → {me.Vector2d}

Divide this vector values by the passed value

Parameters:
Name Type Description
value Number
Returns:
me.Vector2d -

Reference to this object for method chaining

static dotProduct(v) → {Number}

return the dot product of this vector and the passed one

Parameters:
Name Type Description
v me.Vector2d
Returns:
Number -

The dot product.

static equals(v) → {Boolean}

return true if the two vectors are the same

Parameters:
Name Type Description
v me.Vector2d
Returns:
Boolean

static floor() → {me.Vector2d}

Floor the vector values

Returns:
me.Vector2d -

new me.Vector2d

static floorSelf() → {me.Vector2d}

Floor this vector values

Returns:
me.Vector2d -

Reference to this object for method chaining

static length() → {Number}

return the length (magnitude) of this vector

Returns:
Number -

the length of this vector

static length2() → {Number}

return the square length of this vector

Returns:
Number -

The length^2 of this vector.

static lerp(v, alpha) → {me.Vector2d}

Linearly interpolate between this vector and the given one.

Parameters:
Name Type Description
v me.Vector2d
alpha Number

distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).

Returns:
me.Vector2d -

Reference to this object for method chaining

static maxV(v) → {me.Vector2d}

Update this vector with the maximum value between this and the passed vector

Parameters:
Name Type Description
v me.Vector2d
Returns:
me.Vector2d -

Reference to this object for method chaining

static minV(v) → {me.Vector2d}

Update this vector with the minimum value between this and the passed vector

Parameters:
Name Type Description
v me.Vector2d
Returns:
me.Vector2d -

Reference to this object for method chaining

static negate() → {me.Vector2d}

Negate the vector values

Returns:
me.Vector2d -

new me.Vector2d

static negateSelf() → {me.Vector2d}

Negate this vector values

Returns:
me.Vector2d -

Reference to this object for method chaining

static normalize() → {me.Vector2d}

normalize this vector (scale the vector so that its magnitude is 1)

Returns:
me.Vector2d -

Reference to this object for method chaining

static perp() → {me.Vector2d}

change this vector to be perpendicular to what it was before.
(Effectively rotates it 90 degrees in a clockwise direction)

Returns:
me.Vector2d -

Reference to this object for method chaining

static project(v) → {me.Vector2d}

project this vector on to another vector.

Parameters:
Name Type Description
v me.Vector2d

The vector to project onto.

Returns:
me.Vector2d -

Reference to this object for method chaining

static projectN(v) → {me.Vector2d}

Project this vector onto a vector of unit length.
This is slightly more efficient than project when dealing with unit vectors.

Parameters:
Name Type Description
v me.Vector2d

The unit vector to project onto.

Returns:
me.Vector2d -

Reference to this object for method chaining

static rotate(angle) → {me.Vector2d}

Rotate this vector (counter-clockwise) by the specified angle (in radians).

Parameters:
Name Type Description
angle number

The angle to rotate (in radians)

Returns:
me.Vector2d -

Reference to this object for method chaining

static scale(x, yopt) → {me.Vector2d}

Multiply this vector values by the given scalar

Parameters:
Name Type Attributes Default Description
x Number
y Number <optional>
x
Returns:
me.Vector2d -

Reference to this object for method chaining

static scaleV(v) → {me.Vector2d}

Multiply this vector values by the passed vector

Parameters:
Name Type Description
v me.Vector2d
Returns:
me.Vector2d -

Reference to this object for method chaining

static set(x, y) → {me.Vector2d}

set the Vector x and y properties to the given values

Parameters:
Name Type Description
x Number
y Number
Returns:
me.Vector2d -

Reference to this object for method chaining

static setV(v) → {me.Vector2d}

set the Vector x and y properties using the passed vector

Parameters:
Name Type Description
v me.Vector2d
Returns:
me.Vector2d -

Reference to this object for method chaining

static setZero() → {me.Vector2d}

set the Vector x and y properties to 0

Returns:
me.Vector2d -

Reference to this object for method chaining

static sub(v) → {me.Vector2d}

Substract the passed vector to this vector

Parameters:
Name Type Description
v me.Vector2d
Returns:
me.Vector2d -

Reference to this object for method chaining

static to2d() → {me.Vector2d}

Convert this vector into 2d coordinate space

Returns:
me.Vector2d -

Reference to this object for method chaining

static toIso() → {me.Vector2d}

Convert this vector into isometric coordinate space

Returns:
me.Vector2d -

Reference to this object for method chaining

static toString() → {String}

convert the object to a string representation

Returns:
String