2020-07-28 20:21:55 -07:00
|
|
|
|
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [Sweep](sweep.md)
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2020-07-28 20:21:55 -07:00
|
|
|
|
# Class: Sweep
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
This describes the motion of a body/shape for TOI computation. Shapes are
|
|
|
|
|
|
defined with respect to the body origin, which may not coincide with the
|
|
|
|
|
|
center of mass. However, to support dynamics we must interpolate the center
|
|
|
|
|
|
of mass position.
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
## Hierarchy
|
|
|
|
|
|
|
|
|
|
|
|
* **Sweep**
|
|
|
|
|
|
|
|
|
|
|
|
## Index
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
### Constructors
|
|
|
|
|
|
|
|
|
|
|
|
* [constructor](sweep.md#constructor)
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
### Properties
|
|
|
|
|
|
|
|
|
|
|
|
* [a](sweep.md#a)
|
|
|
|
|
|
* [a0](sweep.md#a0)
|
|
|
|
|
|
* [alpha0](sweep.md#alpha0)
|
|
|
|
|
|
* [c](sweep.md#c)
|
|
|
|
|
|
* [c0](sweep.md#c0)
|
|
|
|
|
|
* [localCenter](sweep.md#localcenter)
|
|
|
|
|
|
|
|
|
|
|
|
### Methods
|
|
|
|
|
|
|
|
|
|
|
|
* [advance](sweep.md#advance)
|
|
|
|
|
|
* [clone](sweep.md#clone)
|
|
|
|
|
|
* [forward](sweep.md#forward)
|
|
|
|
|
|
* [getTransform](sweep.md#gettransform)
|
|
|
|
|
|
* [normalize](sweep.md#normalize)
|
|
|
|
|
|
* [set](sweep.md#set)
|
|
|
|
|
|
* [setLocalCenter](sweep.md#setlocalcenter)
|
|
|
|
|
|
* [setTransform](sweep.md#settransform)
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
## Constructors
|
|
|
|
|
|
|
|
|
|
|
|
### constructor
|
|
|
|
|
|
|
|
|
|
|
|
\+ **new Sweep**(`c?`: [Vec2](vec2.md), `a?`: number): *[Sweep](sweep.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:55](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L55)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`c?` | [Vec2](vec2.md) |
|
|
|
|
|
|
`a?` | number |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Sweep](sweep.md)*
|
|
|
|
|
|
|
2020-07-27 00:12:01 -07:00
|
|
|
|
## Properties
|
|
|
|
|
|
|
|
|
|
|
|
### a
|
|
|
|
|
|
|
|
|
|
|
|
• **a**: *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:49](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L49)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
World angle
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### a0
|
|
|
|
|
|
|
|
|
|
|
|
• **a0**: *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:55](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L55)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### alpha0
|
|
|
|
|
|
|
|
|
|
|
|
• **alpha0**: *number*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:52](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L52)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Fraction of the current time step in the range [0,1], c0 and a0 are c and a at alpha0.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### c
|
|
|
|
|
|
|
2021-05-02 17:18:33 -07:00
|
|
|
|
• **c**: *[Vec2](vec2.md)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:46](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L46)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
World center position
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### c0
|
|
|
|
|
|
|
2021-05-02 17:18:33 -07:00
|
|
|
|
• **c0**: *[Vec2](vec2.md)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:54](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L54)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### localCenter
|
|
|
|
|
|
|
2021-05-02 17:18:33 -07:00
|
|
|
|
• **localCenter**: *[Vec2](vec2.md)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:43](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L43)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Local center of mass position
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
## Methods
|
|
|
|
|
|
|
|
|
|
|
|
### advance
|
|
|
|
|
|
|
|
|
|
|
|
▸ **advance**(`alpha`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:105](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L105)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Advance the sweep forward, yielding a new initial state.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`alpha` | number | The new initial time |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### clone
|
|
|
|
|
|
|
|
|
|
|
|
▸ **clone**(): *[Sweep](sweep.md)*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:127](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L127)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *[Sweep](sweep.md)*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### forward
|
|
|
|
|
|
|
|
|
|
|
|
▸ **forward**(): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:113](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L113)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### getTransform
|
|
|
|
|
|
|
|
|
|
|
|
▸ **getTransform**(`xf`: [Transform](transform.md), `beta`: number): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:91](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L91)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
Get the interpolated transform at a specific time.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
Name | Type | Description |
|
|
|
|
|
|
------ | ------ | ------ |
|
|
|
|
|
|
`xf` | [Transform](transform.md) | - |
|
|
|
|
|
|
`beta` | number | A factor in [0,1], where 0 indicates alpha0 |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### normalize
|
|
|
|
|
|
|
|
|
|
|
|
▸ **normalize**(): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:121](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L121)*
|
2021-04-16 17:10:15 +02:00
|
|
|
|
|
|
|
|
|
|
normalize the angles in radians to be between -pi and pi.
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### set
|
|
|
|
|
|
|
2021-04-16 17:10:15 +02:00
|
|
|
|
▸ **set**(`that`: [Sweep](sweep.md)): *void*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:138](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L138)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
2021-04-16 17:10:15 +02:00
|
|
|
|
`that` | [Sweep](sweep.md) |
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setLocalCenter
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setLocalCenter**(`localCenter`: [Vec2](vec2.md), `xf`: [Transform](transform.md)): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:77](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L77)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`localCenter` | [Vec2](vec2.md) |
|
|
|
|
|
|
`xf` | [Transform](transform.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|
|
|
|
|
|
|
|
|
|
|
|
___
|
|
|
|
|
|
|
|
|
|
|
|
### setTransform
|
|
|
|
|
|
|
|
|
|
|
|
▸ **setTransform**(`xf`: [Transform](transform.md)): *void*
|
|
|
|
|
|
|
2021-05-11 18:30:36 -07:00
|
|
|
|
*Defined in [src/common/Sweep.ts:68](https://github.com/shakiba/planck.js/blob/acc3bd8/src/common/Sweep.ts#L68)*
|
2020-07-27 00:12:01 -07:00
|
|
|
|
|
|
|
|
|
|
**Parameters:**
|
|
|
|
|
|
|
|
|
|
|
|
Name | Type |
|
|
|
|
|
|
------ | ------ |
|
|
|
|
|
|
`xf` | [Transform](transform.md) |
|
|
|
|
|
|
|
|
|
|
|
|
**Returns:** *void*
|