API Documentation

for 0.0.1
Show:

Vector2 Class

Represents a 2 dimensionnal Euclidean Vector, to be used as 2D positions, 2D directions or 2D Euler angles (rotation).

This class extends the one from Three.js, API available here : http://threejs.org/docs/#Reference/Math/Vector2

Methods

add

(
  • v
)

Parameters:

Returns:

Vector2

addScalar

(
  • s
)

Add the scalar value s to this vector's x and y values.

Parameters:

  • s Float

Returns:

Vector2

addScaledVector

(
  • v
  • s
)

Parameters:

Returns:

Vector2

addVectors

(
  • a
  • b
)

Parameters:

Returns:

Vector2

angle

()

Returns:

Float

ceil

()

Returns:

Vector2

clamp

(
  • min
  • max
)

If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.

Parameters:

Returns:

Vector2

clampScalar

(
  • min
  • max
)

If this vector's x or y values are greater than the max value, they are replaced by the max value. If this vector's x or y values are less than the min value, they are replaced by the min value.

Parameters:

  • min Float
  • max Float

Returns:

Vector2

clone

()

Returns:

Vector2

copy

(
  • v
)

Parameters:

Returns:

Vector2

distanceTo

(
  • v
)

Parameters:

Returns:

Float

distanceToSquared

(
  • v
)

Parameters:

Returns:

Float

divideScalar

(
  • s
)

Parameters:

  • s Float

Returns:

Vector2

dot

(
  • v
)

Parameters:

Returns:

Float

equals

(
  • v
)

Parameters:

Returns:

Boolean

floor

()

Returns:

Vector2

fromArray

(
  • array
)

Sets this vector's x value to be array[0 and y value to be array[1].

Parameters:

  • array Array

Returns:

Vector2

getComponent

(
  • index
)

if index equals 0 returns the x value. if index equals 1 returns the y value.

Parameters:

  • index Integer

Returns:

Float

length

()

Returns:

Float

lengthManhattan

()

Returns:

Float

lengthSq

()

Returns:

Float

lerp

(
  • v
  • alpha
)

Linear interpolation between this vector and v, where alpha is the percent along the line.

Parameters:

Returns:

Vector2

lerpVectors

(
  • v1
  • v2
  • alpha
)

Sets this vector to be the vector linearly interpolated between v1 and v2 with alpha factor.

Parameters:

Returns:

Vector2

max

(
  • v
)

If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value.

Parameters:

Returns:

Vector2

min

(
  • v
)

If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value.

Parameters:

Returns:

Vector2

multiplyScalar

(
  • s
)

Parameters:

  • s Float

Returns:

Vector2

negate

()

Returns:

Vector2

normalize

()

Returns:

Vector2

round

()

Returns:

Vector2

roundToZero

()

Returns:

Vector2

set

(
  • x
  • y
)

Parameters:

  • x Float
  • y Float

Returns:

Vector2

setComponent

(
  • index
  • value
)

if index equals 0 method replaces this.x with value. if index equals 1 method replaces this.y with value.

Parameters:

  • index Integer
  • value Float

Returns:

undefined

setLength

(
  • l
)

Parameters:

  • l Float

Returns:

Vector2

setX

(
  • x
)

replace this vector's x value with x.

Parameters:

  • x Float

Returns:

Vector2

sub

(
  • v
)

Parameters:

Returns:

Vector2

subVectors

(
  • a
  • b
)

Parameters:

Returns:

Vector2

toArray

(
  • array
)

Returns an array [x, y]

Parameters:

  • array Array

Returns:

Array

Properties

one

Unknown static

Vector2.one returns new Mobilizing.Vector2(1, 1)

zero

Unknown static

Vector2.zero returns new Mobilizing.Vector2(0, 0)