# Vector

Class representing a vector

## Constructor

#### new Vector(ps, pe)

Vector may be constructed by two points, or by two float numbers, or by array of two numbers

Source:
  - classes/vector.js, line 15

##### Parameters:

Name | Type | Description
--- | --- | ---
`ps` | `Point` | start point
`pe` | `Point` | end point

### Classes

Vector

### Members

#### length

Length of vector

Source:
  - classes/vector.js, line 99

#### slope

Slope of the vector in radians from 0 to 2PI

Source:
  - classes/vector.js, line 89

#### x :number

x-coordinate of a vector (float number)

Source:
  - classes/vector.js, line 28

##### Type:

- `number`

#### y :number

y-coordinate of a vector (float number)

Source:
  - classes/vector.js, line 33

##### Type:

- `number`

### Methods

#### add(v) → {Vector}

Return result of addition of other vector to this vector as a new vector

Source:
  - classes/vector.js, line 207

##### Parameters:

Name | Type | Description
--- | --- | ---
`v` | `Vector` | Other vector

##### Returns:

Type:
  `Vector`

#### angleTo(v) → {number}

Return angle between this vector and other vector.
Angle is measured from 0 to 2*PI in the counterclockwise direction from current vector to another.

Source:
  - classes/vector.js, line 227

##### Parameters:

Name | Type | Description
--- | --- | ---
`v` | `Vector` | Another vector

##### Returns:

Type:
  `number`

#### clone() → {Vector}

Method clone returns new instance of Vector

Source:
  - classes/vector.js, line 81

##### Returns:

Type:
  `Vector`

#### cross(v) → {number}

Returns vector product (cross product) of two vectors
`cross_product = (this x v)`

Source:
  - classes/vector.js, line 138

##### Parameters:

Name | Type | Description
--- | --- | ---
`v` | `Vector` | Other vector

##### Returns:

Type:
  `number`

#### dot(v) → {number}

Returns scalar product (dot product) of two vectors
`dot_product = (this * v)`

Source:
  - classes/vector.js, line 128

##### Parameters:

Name | Type | Description
--- | --- | ---
`v` | `Vector` | Other vector

##### Returns:

Type:
  `number`

#### equalTo(v) → {boolean}

Returns true if vectors are equal up to DP_TOL tolerance

Source:
  - classes/vector.js, line 109

##### Parameters:

Name | Type | Description
--- | --- | ---
`v` | `Vector` |

##### Returns:

Type:
  `boolean`

#### invert() → {Vector}

Return inverted vector

Source:
  - classes/vector.js, line 198

##### Returns:

Type:
  `Vector`

#### multiply(scalar) → {Vector}

Returns new vector multiplied by scalar

Source:
  - classes/vector.js, line 118

##### Parameters:

Name | Type | Description
--- | --- | ---
`scalar` | `number` |

##### Returns:

Type:
  `Vector`

#### normalize() → {Vector}

Returns unit vector.
Throw error if given vector has zero length

Source:
  - classes/vector.js, line 147

##### Returns:

Type:
  `Vector`

#### projectionOn(v) → {Vector}

Return vector projection of the current vector on another vector

Source:
  - classes/vector.js, line 240

##### Parameters:

Name | Type | Description
--- | --- | ---
`v` | `Vector` | Another vector

##### Returns:

Type:
  `Vector`

#### rotate(angle) → {Vector}

Returns new vector rotated by given angle, positive angle defines rotation in counterclockwise direction, negative - in clockwise direction Vector only can be rotated around (0,0) point!

Source:
  - classes/vector.js, line 162

##### Parameters:

Name | Type | Description
--- | --- | ---
`angle` | `number` | Angle in radians

##### Returns:

Type:
  `Vector`

#### rotate90CCW() → {Vector}

Returns vector rotated 90 degrees counterclockwise

Source:
  - classes/vector.js, line 182

##### Returns:

Type:
  `Vector`

#### rotate90CW() → {Vector}

Returns vector rotated 90 degrees clockwise

Source:
  - classes/vector.js, line 190

##### Returns:

Type:
  `Vector`

#### subtract(v) → {Vector}

Return result of subtraction of other vector from current vector as a new vector

Source:
  - classes/vector.js, line 216

##### Parameters:

Name | Type | Description
--- | --- | ---
`v` | `Vector` | Another vector

##### Returns:

Type:
  `Vector`

#### transform(m) → {Vector}

Return new vector transformed by affine transformation matrix m

Source:
  - classes/vector.js, line 174

##### Parameters:

Name | Type | Description
--- | --- | ---
`m` | `Matrix` | affine transformation matrix (a,b,c,d,tx,ty)

##### Returns:

Type:
  `Vector`