module:Vector

module:Vector

Vector class

Constructor

# new module:Vector(start, end)

Vector constructor

Parameters:
Name Type Description
start PositionDefinition

Starting vector's position

end PositionDefinition

Ending vector's position

Members

# height

Get this vector vertical component

# length

Return this vector's length

# width

Get this vector horizontal component

Methods

# (static) from(vectorDefinitionopt) → {Vector}

Create a Vector from a generic definition

Parameters:
Name Type Attributes Description
vectorDefinition VectorDefinition <optional>

Vector definition

Returns:
Type
Vector

# add(modification) → {Vector}

Add a vector

Parameters:
Name Type Description
modification VectorDefinition | PositionDefinition | Number

Any Vector or Position or Number

Returns:

Itself

Type
Vector

# clone() → {Vector}

Create a new copy of this vector

Returns:
Type
Vector

# getClosestToPoint(positionDefinition) → {Position}

Find the closest position to a point on this vector

Parameters:
Name Type Description
positionDefinition PositionDefinition

Any position

Returns:
Type
Position

# getDelta() → {Position}

Get the vector move with start at (0, 0)

Returns:
Type
Position

# getIntersectionPoint(vectorDefinition) → {Position}

Return the intersection point between two vector or null if no intersection happen

Parameters:
Name Type Description
vectorDefinition VectorDefinition

Any vector

Returns:
Type
Position

# intersect(vectorDefinition) → {Boolean}

Define if this vector intersect another

Parameters:
Name Type Description
vectorDefinition VectorDefinition

Any vector

Returns:
Type
Boolean

# multiply(modification) → {Vector}

Multiply this vector

Parameters:
Name Type Description
modification VectorDefinition | PositionDefinition | Number

Any Vector or Position or Number

Returns:

Itself

Type
Vector

# toJSON() → {Array.<Array.<Number>>}

Return a JSON ready Vector definition

Returns:
Type
Array.<Array.<Number>>

# translate(modification) → {Vector}

Move this vector

Parameters:
Name Type Description
modification VectorDefinition | PositionDefinition | Number

Any Vector or Position or Number

Returns:

Itself

Type
Vector

# (inner) sanitizeParameters(definition) → {Position|Number}

Accept all kind of type and return only Number or Position

Parameters:
Name Type Description
definition VectorDefinition | PositionDefinition | Number

Value definition

Returns:
Type
Position | Number

Type Definitions

# AbstractVector

Type:
  • Object
Properties
Name Type Attributes Description
start PositionDefinition <optional>

Start coordinates

end PositionDefinition <optional>

End coordinates

# VectorDefinition

Type:
  • Array.<PositionDefinition> | AbstractVector