913 lines
18 KiB
Markdown
Raw Permalink Normal View History

2020-07-28 20:21:55 -07:00
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [Vec2](vec2.md)
# Class: Vec2
## Hierarchy
* **Vec2**
## Index
### Constructors
* [constructor](vec2.md#constructor)
### Properties
* [x](vec2.md#x)
* [y](vec2.md#y)
### Methods
* [add](vec2.md#add)
* [addCombine](vec2.md#addcombine)
* [addMul](vec2.md#addmul)
* [clamp](vec2.md#clamp)
* [clone](vec2.md#clone)
* [length](vec2.md#length)
* [lengthSquared](vec2.md#lengthsquared)
* [mul](vec2.md#mul)
* [neg](vec2.md#neg)
* [normalize](vec2.md#normalize)
* [set](vec2.md#set)
* [setCombine](vec2.md#setcombine)
* [setMul](vec2.md#setmul)
* [setZero](vec2.md#setzero)
* [sub](vec2.md#sub)
* [subCombine](vec2.md#subcombine)
* [subMul](vec2.md#submul)
* [toString](vec2.md#tostring)
2021-04-16 17:10:15 +02:00
* [wSub](vec2.md#wsub)
2020-07-28 20:21:55 -07:00
* [abs](vec2.md#static-abs)
* [add](vec2.md#static-add)
* [addCross](vec2.md#static-addcross)
* [areEqual](vec2.md#static-areequal)
* [assert](vec2.md#static-assert)
* [clamp](vec2.md#static-clamp)
* [clone](vec2.md#static-clone)
* [combine](vec2.md#static-combine)
* [cross](vec2.md#static-cross)
* [distance](vec2.md#static-distance)
* [distanceSquared](vec2.md#static-distancesquared)
* [dot](vec2.md#static-dot)
* [isValid](vec2.md#static-isvalid)
* [lengthOf](vec2.md#static-lengthof)
* [lengthSquared](vec2.md#static-lengthsquared)
* [lower](vec2.md#static-lower)
* [mid](vec2.md#static-mid)
* [mul](vec2.md#static-mul)
* [neg](vec2.md#static-neg)
* [skew](vec2.md#static-skew)
* [sub](vec2.md#static-sub)
* [upper](vec2.md#static-upper)
* [zero](vec2.md#static-zero)
## Constructors
### constructor
\+ **new Vec2**(`x`: number, `y`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:35](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L35)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`x` | number |
`y` | number |
**Returns:** *[Vec2](vec2.md)*
\+ **new Vec2**(`obj`: object): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:37](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L37)*
2021-04-16 17:10:15 +02:00
**Parameters:**
▪ **obj**: *object*
Name | Type |
------ | ------ |
`x` | number |
`y` | number |
**Returns:** *[Vec2](vec2.md)*
\+ **new Vec2**(): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:38](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L38)*
2020-07-28 20:21:55 -07:00
**Returns:** *[Vec2](vec2.md)*
## Properties
### x
• **x**: *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:34](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L34)*
2020-07-28 20:21:55 -07:00
___
### y
• **y**: *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:35](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L35)*
2020-07-28 20:21:55 -07:00
## Methods
### add
▸ **add**(`w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:196](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L196)*
2021-04-16 17:10:15 +02:00
Add a vector to this vector.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
this
2020-07-28 20:21:55 -07:00
___
### addCombine
▸ **addCombine**(`a`: number, `v`: [Vec2](vec2.md), `b`: number, `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:218](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L218)*
2021-04-16 17:10:15 +02:00
Add linear combination of v and w: `a * v + b * w`
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`v` | [Vec2](vec2.md) |
`b` | number |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### addMul
▸ **addMul**(`a`: number, `v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:233](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L233)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### clamp
▸ **clamp**(`max`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:519](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L519)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`max` | number |
**Returns:** *[Vec2](vec2.md)*
___
### clone
▸ **clone**(): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:114](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L114)*
2020-07-28 20:21:55 -07:00
**Returns:** *[Vec2](vec2.md)*
___
### length
▸ **length**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:311](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L311)*
2021-04-16 17:10:15 +02:00
Get the length of this vector (the norm).
For performance, use this instead of lengthSquared (if possible).
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
### lengthSquared
▸ **lengthSquared**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:318](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L318)*
2021-04-16 17:10:15 +02:00
Get the length squared.
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
### mul
▸ **mul**(`m`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:299](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L299)*
2021-04-16 17:10:15 +02:00
Multiply this vector by a scalar.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`m` | number |
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
this
2020-07-28 20:21:55 -07:00
___
### neg
▸ **neg**(): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:485](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L485)*
2020-07-28 20:21:55 -07:00
**Returns:** *[Vec2](vec2.md)*
___
### normalize
▸ **normalize**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:327](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L327)*
2021-04-16 17:10:15 +02:00
Convert this vector into a unit vector.
2020-07-28 20:21:55 -07:00
**Returns:** *number*
2021-04-16 17:10:15 +02:00
old length
2020-07-28 20:21:55 -07:00
___
### set
▸ **set**(`x`: number, `y`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:129](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L129)*
2021-04-16 17:10:15 +02:00
Set this vector to some specified coordinates.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`x` | number |
`y` | number |
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
this
2020-07-28 20:21:55 -07:00
▸ **set**(`value`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:130](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L130)*
2021-04-16 17:10:15 +02:00
Set this vector to some specified coordinates.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`value` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
this
2020-07-28 20:21:55 -07:00
___
### setCombine
▸ **setCombine**(`a`: number, `v`: [Vec2](vec2.md), `b`: number, `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:166](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L166)*
2021-04-16 17:10:15 +02:00
Set linear combination of v and w: `a * v + b * w`
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`v` | [Vec2](vec2.md) |
`b` | number |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### setMul
▸ **setMul**(`a`: number, `v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:180](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L180)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### setZero
▸ **setZero**(): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:123](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L123)*
2021-04-16 17:10:15 +02:00
Set this vector to all zeros.
2020-07-28 20:21:55 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
this
2020-07-28 20:21:55 -07:00
___
### sub
▸ **sub**(`w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:287](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L287)*
2021-04-16 17:10:15 +02:00
Subtract a vector from this vector
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
this
2020-07-28 20:21:55 -07:00
___
### subCombine
▸ **subCombine**(`a`: number, `v`: [Vec2](vec2.md), `b`: number, `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:257](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L257)*
2021-04-16 17:10:15 +02:00
Subtract linear combination of v and w: `a * v + b * w`
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`v` | [Vec2](vec2.md) |
`b` | number |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### subMul
▸ **subMul**(`a`: number, `v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:271](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L271)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### toString
▸ **toString**(): *string*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:95](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L95)*
2020-07-28 20:21:55 -07:00
**Returns:** *string*
___
2021-04-16 17:10:15 +02:00
### wSub
2021-05-11 18:30:36 -07:00
▸ **wSub**(`a`: number, `v`: [Vec2](vec2.md), `b?`: number, `w?`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:247](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L247)*
2021-04-16 17:10:15 +02:00
**`deprecated`** Use subCombine or subMul
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`a` | number |
`v` | [Vec2](vec2.md) |
`b?` | number |
`w?` | [Vec2](vec2.md) |
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
2020-07-28 20:21:55 -07:00
### `Static` abs
▸ **abs**(`v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:496](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L496)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` add
▸ **add**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:444](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L444)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` addCross
▸ **addCross**(`a`: [Vec2](vec2.md), `v`: [Vec2](vec2.md), `w`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:423](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L423)*
2021-04-16 17:10:15 +02:00
Returns `a + (v x w)`
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Vec2](vec2.md) |
`v` | [Vec2](vec2.md) |
`w` | number |
**Returns:** *[Vec2](vec2.md)*
▸ **addCross**(`a`: [Vec2](vec2.md), `v`: number, `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:424](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L424)*
2021-04-16 17:10:15 +02:00
Returns `a + (v x w)`
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Vec2](vec2.md) |
`v` | number |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` areEqual
▸ **areEqual**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *boolean*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:372](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L372)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *boolean*
___
### `Static` assert
▸ **assert**(`o`: any): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:106](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L106)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`o` | any |
**Returns:** *void*
___
### `Static` clamp
▸ **clamp**(`v`: [Vec2](vec2.md), `max`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:529](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L529)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`max` | number |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` clone
▸ **clone**(`v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:90](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L90)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` combine
▸ **combine**(`a`: number, `v`: [Vec2](vec2.md), `b`: number, `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:459](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L459)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`v` | [Vec2](vec2.md) |
`b` | number |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` cross
▸ **cross**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:395](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L395)*
2021-04-16 17:10:15 +02:00
Perform the cross product on two vectors. In 2D this produces a scalar.
Perform the cross product on a vector and a scalar. In 2D this produces a
vector.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *number*
▸ **cross**(`v`: [Vec2](vec2.md), `w`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:396](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L396)*
2021-04-16 17:10:15 +02:00
Perform the cross product on two vectors. In 2D this produces a scalar.
Perform the cross product on a vector and a scalar. In 2D this produces a
vector.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | number |
**Returns:** *[Vec2](vec2.md)*
▸ **cross**(`v`: number, `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:397](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L397)*
2021-04-16 17:10:15 +02:00
Perform the cross product on two vectors. In 2D this produces a scalar.
Perform the cross product on a vector and a scalar. In 2D this produces a
vector.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | number |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` distance
▸ **distance**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:356](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L356)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *number*
___
### `Static` distanceSquared
▸ **distanceSquared**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:364](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L364)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *number*
___
### `Static` dot
▸ **dot**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:389](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L389)*
2021-04-16 17:10:15 +02:00
Perform the dot product on two vectors.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *number*
___
### `Static` isValid
▸ **isValid**(`v`: any): *boolean*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:102](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L102)*
2021-04-16 17:10:15 +02:00
Does this vector contain finite coordinates?
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | any |
**Returns:** *boolean*
___
### `Static` lengthOf
▸ **lengthOf**(`v`: [Vec2](vec2.md)): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:343](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L343)*
2021-04-16 17:10:15 +02:00
Get the length of this vector (the norm).
For performance, use this instead of lengthSquared (if possible).
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
**Returns:** *number*
___
### `Static` lengthSquared
▸ **lengthSquared**(`v`: [Vec2](vec2.md)): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:351](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L351)*
2021-04-16 17:10:15 +02:00
Get the length squared.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
**Returns:** *number*
___
### `Static` lower
▸ **lower**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:513](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L513)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` mid
▸ **mid**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:501](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L501)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` mul
▸ **mul**(`a`: [Vec2](vec2.md), `b`: number): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:469](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L469)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Vec2](vec2.md) |
`b` | number |
**Returns:** *[Vec2](vec2.md)*
▸ **mul**(`a`: number, `b`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:470](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L470)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`b` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` neg
▸ **neg**(`v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:491](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L491)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` skew
▸ **skew**(`v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:381](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L381)*
2021-04-16 17:10:15 +02:00
Get the skew vector such that dot(skew_vec, other) == cross(vec, other)
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` sub
▸ **sub**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:463](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L463)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` upper
▸ **upper**(`v`: [Vec2](vec2.md), `w`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:507](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L507)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
`w` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` zero
▸ **zero**(): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Vec2.ts:75](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Vec2.ts#L75)*
2020-07-28 20:21:55 -07:00
**Returns:** *[Vec2](vec2.md)*