406 lines
8.3 KiB
Markdown
Raw Permalink Normal View History

2020-07-28 20:21:55 -07:00
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [Mat22](mat22.md)
# Class: Mat22
2021-04-16 17:10:15 +02:00
A 2-by-2 matrix. Stored in column-major order.
2020-07-28 20:21:55 -07:00
## Hierarchy
* **Mat22**
## Index
### Constructors
* [constructor](mat22.md#constructor)
### Properties
* [ex](mat22.md#ex)
* [ey](mat22.md#ey)
### Methods
* [getInverse](mat22.md#getinverse)
* [set](mat22.md#set)
* [setIdentity](mat22.md#setidentity)
* [setZero](mat22.md#setzero)
* [solve](mat22.md#solve)
* [toString](mat22.md#tostring)
* [abs](mat22.md#static-abs)
* [add](mat22.md#static-add)
* [assert](mat22.md#static-assert)
* [isValid](mat22.md#static-isvalid)
* [mul](mat22.md#static-mul)
* [mulMat22](mat22.md#static-mulmat22)
* [mulT](mat22.md#static-mult)
2021-04-16 17:10:15 +02:00
* [mulTMat22](mat22.md#static-multmat22)
* [mulTVec2](mat22.md#static-multvec2)
2020-07-28 20:21:55 -07:00
* [mulVec2](mat22.md#static-mulvec2)
## Constructors
### constructor
\+ **new Mat22**(`a`: number, `b`: number, `c`: number, `d`: number): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:38](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L38)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`b` | number |
`c` | number |
`d` | number |
**Returns:** *[Mat22](mat22.md)*
\+ **new Mat22**(`a`: object, `b`: object): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:40](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L40)*
2021-04-16 17:10:15 +02:00
**Parameters:**
▪ **a**: *object*
Name | Type |
------ | ------ |
`x` | number |
`y` | number |
▪ **b**: *object*
Name | Type |
------ | ------ |
`x` | number |
`y` | number |
**Returns:** *[Mat22](mat22.md)*
\+ **new Mat22**(): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:41](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L41)*
2020-07-28 20:21:55 -07:00
**Returns:** *[Mat22](mat22.md)*
## Properties
### ex
• **ex**: *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:37](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L37)*
2020-07-28 20:21:55 -07:00
___
### ey
• **ey**: *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:38](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L38)*
2020-07-28 20:21:55 -07:00
## Methods
### getInverse
▸ **getInverse**(): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:111](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L111)*
2020-07-28 20:21:55 -07:00
**Returns:** *[Mat22](mat22.md)*
___
### set
▸ **set**(`a`: [Mat22](mat22.md)): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:73](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L73)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Mat22](mat22.md) |
**Returns:** *void*
▸ **set**(`a`: [Vec2](vec2.md), `b`: [Vec2](vec2.md)): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:74](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L74)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Vec2](vec2.md) |
`b` | [Vec2](vec2.md) |
**Returns:** *void*
▸ **set**(`a`: number, `b`: number, `c`: number, `d`: number): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:75](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L75)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | number |
`b` | number |
`c` | number |
`d` | number |
**Returns:** *void*
___
### setIdentity
▸ **setIdentity**(): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:97](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L97)*
2020-07-28 20:21:55 -07:00
**Returns:** *void*
___
### setZero
▸ **setZero**(): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:104](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L104)*
2020-07-28 20:21:55 -07:00
**Returns:** *void*
___
### solve
▸ **solve**(`v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:132](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L132)*
2021-04-16 17:10:15 +02:00
Solve A * x = b, where b is a column vector. This is more efficient than
computing the inverse in one-shot cases.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### toString
▸ **toString**(): *string*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:57](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L57)*
2020-07-28 20:21:55 -07:00
**Returns:** *string*
___
### `Static` abs
▸ **abs**(`mx`: [Mat22](mat22.md)): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:229](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L229)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`mx` | [Mat22](mat22.md) |
**Returns:** *[Mat22](mat22.md)*
___
### `Static` add
▸ **add**(`mx1`: [Mat22](mat22.md), `mx2`: [Mat22](mat22.md)): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:234](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L234)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`mx1` | [Mat22](mat22.md) |
`mx2` | [Mat22](mat22.md) |
**Returns:** *[Mat22](mat22.md)*
___
### `Static` assert
▸ **assert**(`o`: any): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:65](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L65)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`o` | any |
**Returns:** *void*
___
### `Static` isValid
▸ **isValid**(`o`: any): *boolean*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:61](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L61)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`o` | any |
**Returns:** *boolean*
___
### `Static` mul
▸ **mul**(`mx`: [Mat22](mat22.md), `my`: [Mat22](mat22.md)): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:152](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L152)*
2021-04-16 17:10:15 +02:00
Multiply a matrix times a vector. If a rotation matrix is provided, then this
transforms the vector from one frame to another.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`mx` | [Mat22](mat22.md) |
`my` | [Mat22](mat22.md) |
**Returns:** *[Mat22](mat22.md)*
▸ **mul**(`mx`: [Mat22](mat22.md), `v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:153](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L153)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`mx` | [Mat22](mat22.md) |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` mulMat22
2021-05-11 18:30:36 -07:00
▸ **mulMat22**(`mx`: [Mat22](mat22.md), `v`: [Mat22](mat22.md)): *[Mat22](mat22.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:182](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L182)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`mx` | [Mat22](mat22.md) |
`v` | [Mat22](mat22.md) |
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Mat22](mat22.md)*
2020-07-28 20:21:55 -07:00
___
### `Static` mulT
▸ **mulT**(`mx`: [Mat22](mat22.md), `my`: [Mat22](mat22.md)): *[Mat22](mat22.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:197](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L197)*
2021-04-16 17:10:15 +02:00
Multiply a matrix transpose times a vector. If a rotation matrix is provided,
then this transforms the vector from one frame to another (inverse
transform).
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`mx` | [Mat22](mat22.md) |
`my` | [Mat22](mat22.md) |
**Returns:** *[Mat22](mat22.md)*
▸ **mulT**(`mx`: [Mat22](mat22.md), `v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:198](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L198)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`mx` | [Mat22](mat22.md) |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
2021-04-16 17:10:15 +02:00
### `Static` mulTMat22
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
▸ **mulTMat22**(`mx`: [Mat22](mat22.md), `v`: [Mat22](mat22.md)): *[Mat22](mat22.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:221](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L221)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`mx` | [Mat22](mat22.md) |
`v` | [Mat22](mat22.md) |
**Returns:** *[Mat22](mat22.md)*
___
### `Static` mulTVec2
▸ **mulTVec2**(`mx`: [Mat22](mat22.md), `v`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Mat22.ts:215](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L215)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`mx` | [Mat22](mat22.md) |
`v` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
### `Static` mulVec2
2021-05-11 18:30:36 -07:00
▸ **mulVec2**(`mx`: [Mat22](mat22.md), `v`: [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/Mat22.ts:175](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Mat22.ts#L175)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`mx` | [Mat22](mat22.md) |
`v` | [Vec2](vec2.md) |
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*