ObservableVector2d

class ObservableVector2d extends Vector2d

A Vector2d object that provide notification by executing the given callback when the vector is changed.

Constructor


new ObservableVector2d(x: number, y: number, settings: object) → {}
Parameters:
Name Type Attributes Default Description
x number 0

x value of the vector

y number 0

y value of the vector

settings object

additional required parameters

settings.onUpdate Function

the callback to be executed when the vector is changed

settings.scope Function

<optional>

the value to use as this when calling onUpdate

Summary


Properties from ObservableVector2d

number
x
number
y

Public Properties


x observable_vector2.js:39
x: number

number

x value of the vector

y observable_vector2.js:61
y: number

number

y value of the vector

Public Methods


abs observable_vector2.js:184
abs() → {ObservableVector2d}

Update this vector values to absolute values

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

add observable_vector2.js:128
add(v: ObservableVector2d) → {ObservableVector2d}

Add the passed vector to this vector

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

ceil observable_vector2.js:260
ceil() → {ObservableVector2d}

Ceil the vector values

Returns:
Type Description
ObservableVector2d

new me.ObservableVector2d

ceilSelf observable_vector2.js:270
ceilSelf() → {ObservableVector2d}

Ceil this vector values

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

clamp observable_vector2.js:194
clamp(low: number, high: number) → {ObservableVector2d}

Clamp the vector value within the specified value range

Parameters:
Name Type Description
low number
high number
Returns:
Type Description
ObservableVector2d

new me.ObservableVector2d

clampSelf observable_vector2.js:206
clampSelf(low: number, high: number) → {ObservableVector2d}

Clamp this vector value within the specified value range

Parameters:
Name Type Description
low number
high number
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

clone observable_vector2.js:430
clone() → {ObservableVector2d}

return a clone copy of this vector

Returns:
Type Description
ObservableVector2d

new me.ObservableVector2d

copy observable_vector2.js:300
copy(v: ObservableVector2d) → {ObservableVector2d}

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

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

cross observable_vector2.js:370
cross(v: Vector2d | ObservableVector2d) → {number}

return the cross product of this vector and the passed one

Parameters:
Name Type Description
v Vector2d | ObservableVector2d
Returns:
Type Description
number

The cross product.

distance observable_vector2.js:419
distance(v: ObservableVector2d) → {number}

return the distance between this vector and the passed one

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
number
div observable_vector2.js:173
div(n: number) → {ObservableVector2d}

Divide this vector values by the passed value

Parameters:
Name Type Description
n number

the value to divide the vector by

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

dot observable_vector2.js:359
dot(v: Vector2d | ObservableVector2d) → {number}

return the dot product of this vector and the passed one

Parameters:
Name Type Description
v Vector2d | ObservableVector2d
Returns:
Type Description
number

The dot product.

equals observable_vector2.js:311
equals(v: ObservableVector2d) → {boolean}

return true if the two vectors are the same

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
boolean
floor observable_vector2.js:240
floor() → {ObservableVector2d}

Floor the vector values

Returns:
Type Description
ObservableVector2d

new me.ObservableVector2d

floorSelf observable_vector2.js:250
floorSelf() → {ObservableVector2d}

Floor this vector values

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

lerp observable_vector2.js:381
lerp(v: Vector2d | ObservableVector2d, alpha: number) → {ObservableVector2d}

Linearly interpolate between this vector and the given one.

Parameters:
Name Type Description
v Vector2d | ObservableVector2d
alpha number

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

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

maxV observable_vector2.js:229
maxV(v: ObservableVector2d) → {ObservableVector2d}

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

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

minV observable_vector2.js:218
minV(v: ObservableVector2d) → {ObservableVector2d}

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

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

moveTowards observable_vector2.js:396
moveTowards(target: Vector2d | ObservableVector2d, step: number) → {ObservableVector2d}

interpolate the position of this vector towards the given one while nsure that the distance never exceeds the given step.

Parameters:
Name Type Description
target Vector2d | ObservableVector2d
step number

the maximum step per iteration (Negative values will push the vector away from the target)

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

negate observable_vector2.js:280
negate() → {ObservableVector2d}

Negate the vector values

Returns:
Type Description
ObservableVector2d

new me.ObservableVector2d

negateSelf observable_vector2.js:290
negateSelf() → {ObservableVector2d}

Negate this vector values

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

perp observable_vector2.js:322
perp() → {ObservableVector2d}

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

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

rotate observable_vector2.js:333
rotate(angle: number, v: Vector2d | ObservableVector2d) → {ObservableVector2d}

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 Vector2d | ObservableVector2d

<optional>

an optional point to rotate around

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

scale observable_vector2.js:150
scale(x: number, y: number) → {ObservableVector2d}

Multiply this vector values by the given scalar

Parameters:
Name Type Attributes Default Description
x number
y number

<optional>

x
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

scaleV observable_vector2.js:162
scaleV(v: ObservableVector2d) → {ObservableVector2d}

Multiply this vector values by the passed vector

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

setCallback observable_vector2.js:109
setCallback(fn: Function, scope: Function) → {ObservableVector2d}

set the callback to be executed when the vector is changed

Parameters:
Name Type Attributes Default Description
fn Function

callback

scope Function

<optional>

null

scope

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

setMuted observable_vector2.js:95
setMuted(x: number, y: number) → {ObservableVector2d}

set the vector value without triggering the callback

Parameters:
Name Type Description
x number

x value of the vector

y number

y value of the vector

Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

sub observable_vector2.js:139
sub(v: ObservableVector2d) → {ObservableVector2d}

Substract the passed vector to this vector

Parameters:
Name Type Description
v ObservableVector2d
Returns:
Type Description
ObservableVector2d

Reference to this object for method chaining

toString observable_vector2.js:450
toString() → {string}

convert the object to a string representation

Returns:
Type Description
string
toVector2d observable_vector2.js:440
toVector2d() → {Vector2d}

return a me.Vector2d copy of this me.ObservableVector2d object

Returns:
Type Description
Vector2d

new me.Vector2d


Powered by webdoc!