# Class: Vec2

## Vec2

#### new Vec2(x, y)

  2-dimension Cartesian vector with built-in (optional) object pool.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | Number |
  `y` | Number |

  Source:
    - Vec2.js, line 11

### Methods

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

  Add some vector to this one.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 147

  ##### Returns:

  This vector.
  Type
    Vec2

#### angle() → {Number}

  Get the angle of this vector.
  Source:
    - Vec2.js, line 222

  ##### Returns:

  Type
    Number

#### angleBetween(v) → {Number}

  Get the angle between this vector and another.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 232

  ##### Returns:

  Type
    Number

#### assign(v) → {Vec2}

  Assign this vector the value of another.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 70

  ##### Returns:

  This vector.
  Type
    Vec2

#### clear() → {Vec2}

  Reset this vector to (0,0).
  Source:
    - Vec2.js, line 59

  ##### Returns:

  This vector.
  Type
    Vec2

#### copy() → {Vec2}

  Make a copy of this vector.
  Source:
    - Vec2.js, line 250

  ##### Returns:

  A new vector.
  Type
    Vec2

#### det(v) → {Number}

  Get the determinate of this vector and another.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 195

  ##### Returns:

  Type
    Number

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

  Get the dot product of this vector and another.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 185

  ##### Returns:

  Type
    Number

#### equals(v) → {Boolean}

  Determine if this vector is equal to another.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 82

  ##### Returns:

  True if vectors are equal.
  Type
    Boolean

#### limit(size) → {Vec2}

  Limit this vector to a specific magnitude.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `size` | Number |

  Source:
    - Vec2.js, line 105

  ##### Returns:

  This vector.
  Type
    Vec2

#### magnitude() → {Number}

  Get the magnitude of this vector.
  Source:
    - Vec2.js, line 204

  ##### Returns:

  Type
    Number

#### magnitude2() → {Number}

  Get the squared magnitude of this vector.
  Source:
    - Vec2.js, line 213

  ##### Returns:

  Type
    Number

#### normalize(m) → {Vec2}

  Normalize this vector.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `m` | Number | <optional> | Length.

  Source:
    - Vec2.js, line 121

  ##### Returns:

  This vector.
  Type
    Vec2

#### pcopy() → {Vec2}

  Make a pooled copy of this vector
  Source:
    - Vec2.js, line 241

  ##### Returns:

  A new vector.
  Type
    Vec2

#### rotate(theta) → {Vec2}

  Rotate this vector clockwise about the origin by a certain angle.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `theta` | Number |

  Source:
    - Vec2.js, line 172

  ##### Returns:

  This vector.
  Type
    Vec2

#### set(x, y) → {Vec2}

  Set this vector to a set of coordinates.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `x` | Number |
  `y` | Number |

  Source:
    - Vec2.js, line 93

  ##### Returns:

  This vector.
  Type
    Vec2

#### smult(n) → {Vec2}

  Scalar multiply this vector by a value.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `n` | Number |

  Source:
    - Vec2.js, line 159

  ##### Returns:

  This vector.
  Type
    Vec2

#### sub(v) → {Vec2}

  Subtract some vector from this one.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 135

  ##### Returns:

  This vector.
  Type
    Vec2

#### toString()

  Output this vector.
  Source:
    - Vec2.js, line 339

#### <static> aquire() → {Vec2}

  Source:
    - Vec2.js, line 27

  ##### Returns:

  Vector from the pool.
  Type
    Vec2

#### <static> fromAngle(theta, m) → {Vec2}

  Create a vector with a specific angle and magnitude.

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `theta` | Number |  |
  `m` | Number | <optional> |

  Source:
    - Vec2.js, line 261

  ##### Returns:

  A new vector.
  Type
    Vec2

#### <static> pfromAngle(theta, m) → {Vec2}

  Create a pooled vector with a specific angle and magnitude.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `theta` | Number |
  `m` | Number |

  Source:
    - Vec2.js, line 273

  ##### Returns:

  A new vector.
  Type
    Vec2

#### <static> rectContains(p1, r1, p2, r2) → {Boolean}

  Determines if rectangle 1 is entirely inside of rectangle 2.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `p1` | Vec2 | Position of rectangle 1
  `r1` | Vec2 | Halfwidths of rectangle 1
  `p2` | Vec2 | Position of rectangle 2
  `r2` | Vec2 | Halfwidths of rectangle 2

  Source:
    - Vec2.js, line 312

  ##### Returns:

  True if they rectangle 1 is inside of rectangle 2
  Type
    Boolean

#### <static> rectIntersect(p1, r1, p2, r2) → {Boolean}

  Determine if two rectangles, defined by a position and a halfwidth vector, overlap.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `p1` | Vec2 | Position of rectangle 1
  `r1` | Vec2 | Halfwidths of rectangle 1
  `p2` | Vec2 | Position of rectangle 2
  `r2` | Vec2 | Halfwidths of rectangle 2

  Source:
    - Vec2.js, line 291

  ##### Returns:

  True if they intersect
  Type
    Boolean

#### <static> release(v) → {Number}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `v` | Vec2 |

  Source:
    - Vec2.js, line 48

  ##### Returns:

  Current pool count.
  Type
    Number

#### <static> sizeToHwidth(position, size, out__position, out__hwidth)

  Convert a rectangle specified by top-left point + size into center location + halfwidths.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `position` | Vec2 |
  `size` | Vec2 |
  `out__position` | Vec2 | Output position
  `out__hwidth` | Vec2 | Output hwidths

  Source:
    - Vec2.js, line 330