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
-
static add(v) → {me.Vector2d}
-
Add the passed vector to this vector
Parameters:
Name Type Description v
me.Vector2d -
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
-
static ceilSelf() → {me.Vector2d}
-
Ceil this vector values
-
static clamp(low, high) → {me.Vector2d}
-
Clamp the vector value within the specified value range
Parameters:
Name Type Description low
Number high
Number -
static clampSelf(low, high) → {me.Vector2d}
-
Clamp this vector value within the specified value range
Parameters:
Name Type Description low
Number high
Number -
static clone() → {me.Vector2d}
-
return a clone copy of this vector
-
static copy(v) → {me.Vector2d}
-
Copy the x,y values of the passed vector to this one
Parameters:
Name Type Description v
me.Vector2d -
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 -
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
-
static floorSelf() → {me.Vector2d}
-
Floor this vector values
-
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).
-
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 -
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 -
static negate() → {me.Vector2d}
-
Negate the vector values
-
static negateSelf() → {me.Vector2d}
-
Negate this vector values
-
static normalize() → {me.Vector2d}
-
normalize this vector (scale the vector so that its magnitude is 1)
-
static perp() → {me.Vector2d}
-
change this vector to be perpendicular to what it was before.
(Effectively rotates it 90 degrees in a clockwise direction) -
static project(v) → {me.Vector2d}
-
project this vector on to another vector.
Parameters:
Name Type Description v
me.Vector2d The vector to project onto.
-
static projectN(v) → {me.Vector2d}
-
Project this vector onto a vector of unit length.
This is slightly more efficient thanproject
when dealing with unit vectors.Parameters:
Name Type Description v
me.Vector2d The unit vector to project onto.
-
static rotate(angle, vopt) → {me.Vector2d}
-
Rotate this vector (counter-clockwise) by the specified angle (in radians).
Parameters:
Name Type Attributes Description angle
number The angle to rotate (in radians)
v
me.Vector2d | me.ObservableVector2d <optional>
an optional point to rotate around
-
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 -
static scaleV(v) → {me.Vector2d}
-
Multiply this vector values by the passed vector
Parameters:
Name Type Description v
me.Vector2d -
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 -
static setV(v) → {me.Vector2d}
-
set the Vector x and y properties using the passed vector
Parameters:
Name Type Description v
me.Vector2d -
static setZero() → {me.Vector2d}
-
set the Vector x and y properties to 0
-
static sub(v) → {me.Vector2d}
-
Substract the passed vector to this vector
Parameters:
Name Type Description v
me.Vector2d -
static to2d() → {me.Vector2d}
-
Convert this vector into 2d coordinate space
-
static toIso() → {me.Vector2d}
-
Convert this vector into isometric coordinate space
-
static toString() → {String}
-
convert the object to a string representation
Returns:
String