337 lines
7.5 KiB
Markdown
Raw Permalink Normal View History

2020-07-28 20:21:55 -07:00
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [Transform](transform.md)
# Class: Transform
2021-04-16 17:10:15 +02:00
A transform contains translation and rotation. It is used to represent the
position and orientation of rigid frames. Initialize using a position vector
and a rotation.
2020-07-28 20:21:55 -07:00
## Hierarchy
* **Transform**
## Index
### Constructors
* [constructor](transform.md#constructor)
### Properties
* [p](transform.md#p)
* [q](transform.md#q)
### Methods
* [set](transform.md#set)
* [setIdentity](transform.md#setidentity)
* [assert](transform.md#static-assert)
* [clone](transform.md#static-clone)
* [identity](transform.md#static-identity)
* [isValid](transform.md#static-isvalid)
* [mul](transform.md#static-mul)
2021-04-16 17:10:15 +02:00
* [mulAll](transform.md#static-mulall)
2020-07-28 20:21:55 -07:00
* [mulT](transform.md#static-mult)
* [mulTVec2](transform.md#static-multvec2)
* [mulTXf](transform.md#static-multxf)
* [mulVec2](transform.md#static-mulvec2)
* [mulXf](transform.md#static-mulxf)
## Constructors
### constructor
2021-04-16 17:10:15 +02:00
\+ **new Transform**(`position?`: [Vec2](vec2.md), `rotation?`: number): *[Transform](transform.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:44](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L44)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
2021-04-16 17:10:15 +02:00
`position?` | [Vec2](vec2.md) |
`rotation?` | number |
2020-07-28 20:21:55 -07:00
**Returns:** *[Transform](transform.md)*
## Properties
### p
• **p**: *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:41](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L41)*
2021-04-16 17:10:15 +02:00
position
2020-07-28 20:21:55 -07:00
___
### q
• **q**: *[Rot](rot.md)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:44](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L44)*
2020-07-28 20:21:55 -07:00
2021-04-16 17:10:15 +02:00
rotation
2020-07-28 20:21:55 -07:00
## Methods
### set
▸ **set**(`position`: [Vec2](vec2.md), `rotation`: number): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:90](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L90)*
2021-04-16 17:10:15 +02:00
Set this based on the position and angle.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`position` | [Vec2](vec2.md) |
`rotation` | number |
**Returns:** *void*
▸ **set**(`xf`: [Transform](transform.md)): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:91](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L91)*
2021-04-16 17:10:15 +02:00
Set this based on the position and angle.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`xf` | [Transform](transform.md) |
**Returns:** *void*
___
### setIdentity
▸ **setIdentity**(): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:85](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L85)*
2021-04-16 17:10:15 +02:00
Set this to the identity transform.
2020-07-28 20:21:55 -07:00
**Returns:** *void*
___
### `Static` assert
▸ **assert**(`o`: any): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:110](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L110)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`o` | any |
**Returns:** *void*
___
### `Static` clone
▸ **clone**(`xf`: [Transform](transform.md)): *[Transform](transform.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:60](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L60)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`xf` | [Transform](transform.md) |
**Returns:** *[Transform](transform.md)*
___
### `Static` identity
▸ **identity**(): *[Transform](transform.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:75](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L75)*
2020-07-28 20:21:55 -07:00
**Returns:** *[Transform](transform.md)*
___
### `Static` isValid
▸ **isValid**(`o`: any): *boolean*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:106](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L106)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`o` | any |
**Returns:** *boolean*
___
### `Static` mul
▸ **mul**(`a`: [Transform](transform.md), `b`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:118](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L118)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
▸ **mul**(`a`: [Transform](transform.md), `b`: [Transform](transform.md)): *[Transform](transform.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:119](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L119)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Transform](transform.md) |
**Returns:** *[Transform](transform.md)*
2021-04-16 17:10:15 +02:00
___
### `Static` mulAll
▸ **mulAll**(`a`: [Transform](transform.md), `b`: [Vec2](vec2.md)[]): *[Vec2](vec2.md)[]*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:140](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L140)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Vec2](vec2.md)[] |
**Returns:** *[Vec2](vec2.md)[]*
2021-04-16 17:10:15 +02:00
▸ **mulAll**(`a`: [Transform](transform.md), `b`: [Transform](transform.md)[]): *[Transform](transform.md)[]*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:141](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L141)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Transform](transform.md)[] |
**Returns:** *[Transform](transform.md)[]*
2021-04-16 17:10:15 +02:00
___
2020-07-28 20:21:55 -07:00
### `Static` mulT
▸ **mulT**(`a`: [Transform](transform.md), `b`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:180](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L180)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
▸ **mulT**(`a`: [Transform](transform.md), `b`: [Transform](transform.md)): *[Transform](transform.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:181](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L181)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Transform](transform.md) |
**Returns:** *[Transform](transform.md)*
___
### `Static` mulTVec2
▸ **mulTVec2**(`a`: [Transform](transform.md), `b`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:192](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L192)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` mulTXf
▸ **mulTXf**(`a`: [Transform](transform.md), `b`: [Transform](transform.md)): *[Transform](transform.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:202](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L202)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Transform](transform.md) |
**Returns:** *[Transform](transform.md)*
___
### `Static` mulVec2
▸ **mulVec2**(`a`: [Transform](transform.md), `b`: [Vec2](vec2.md)): *[Vec2](vec2.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:161](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L161)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Vec2](vec2.md) |
**Returns:** *[Vec2](vec2.md)*
___
### `Static` mulXf
▸ **mulXf**(`a`: [Transform](transform.md), `b`: [Transform](transform.md)): *[Transform](transform.md)*
2021-05-11 18:30:36 -07:00
*Defined in [src/common/Transform.ts:169](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Transform.ts#L169)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`a` | [Transform](transform.md) |
`b` | [Transform](transform.md) |
**Returns:** *[Transform](transform.md)*