448 lines
11 KiB
Markdown
Raw Permalink Normal View History

2020-07-28 20:21:55 -07:00
[Planck.js API Doc](../README.md) › [Globals](../globals.md) › [WeldJoint](weldjoint.md)
# Class: WeldJoint
2021-04-16 17:10:15 +02:00
A weld joint essentially glues two bodies together. A weld joint may distort
somewhat because the island constraint solver is approximate.
2020-07-28 20:21:55 -07:00
## Hierarchy
* [Joint](joint.md)
2021-04-16 17:10:15 +02:00
2020-07-28 20:21:55 -07:00
↳ **WeldJoint**
## Index
### Constructors
* [constructor](weldjoint.md#constructor)
### Properties
* [TYPE](weldjoint.md#static-type)
### Methods
2021-04-16 17:10:15 +02:00
* [getAnchorA](weldjoint.md#getanchora)
* [getAnchorB](weldjoint.md#getanchorb)
* [getBodyA](weldjoint.md#getbodya)
* [getBodyB](weldjoint.md#getbodyb)
* [getCollideConnected](weldjoint.md#getcollideconnected)
2020-07-28 20:21:55 -07:00
* [getDampingRatio](weldjoint.md#getdampingratio)
* [getFrequency](weldjoint.md#getfrequency)
* [getLocalAnchorA](weldjoint.md#getlocalanchora)
* [getLocalAnchorB](weldjoint.md#getlocalanchorb)
2021-04-16 17:10:15 +02:00
* [getNext](weldjoint.md#getnext)
* [getReactionForce](weldjoint.md#getreactionforce)
* [getReactionTorque](weldjoint.md#getreactiontorque)
2020-07-28 20:21:55 -07:00
* [getReferenceAngle](weldjoint.md#getreferenceangle)
2021-04-16 17:10:15 +02:00
* [getType](weldjoint.md#gettype)
* [getUserData](weldjoint.md#getuserdata)
* [initVelocityConstraints](weldjoint.md#initvelocityconstraints)
* [isActive](weldjoint.md#isactive)
2020-07-28 20:21:55 -07:00
* [setDampingRatio](weldjoint.md#setdampingratio)
* [setFrequency](weldjoint.md#setfrequency)
2021-04-16 17:10:15 +02:00
* [setUserData](weldjoint.md#setuserdata)
* [shiftOrigin](weldjoint.md#shiftorigin)
* [solvePositionConstraints](weldjoint.md#solvepositionconstraints)
* [solveVelocityConstraints](weldjoint.md#solvevelocityconstraints)
2020-07-28 20:21:55 -07:00
## Constructors
### constructor
\+ **new WeldJoint**(`def`: [WeldJointDef](../interfaces/weldjointdef.md)): *[WeldJoint](weldjoint.md)*
*Overrides [Joint](joint.md).[constructor](joint.md#constructor)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:114](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L114)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`def` | [WeldJointDef](../interfaces/weldjointdef.md) |
**Returns:** *[WeldJoint](weldjoint.md)*
\+ **new WeldJoint**(`def`: [WeldJointOpt](../interfaces/weldjointopt.md), `bodyA`: [Body](body.md), `bodyB`: [Body](body.md), `anchor`: [Vec2](vec2.md)): *[WeldJoint](weldjoint.md)*
*Overrides [Joint](joint.md).[constructor](joint.md#constructor)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:116](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L116)*
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`def` | [WeldJointOpt](../interfaces/weldjointopt.md) |
`bodyA` | [Body](body.md) |
`bodyB` | [Body](body.md) |
`anchor` | [Vec2](vec2.md) |
**Returns:** *[WeldJoint](weldjoint.md)*
## Properties
### `Static` TYPE
2021-04-16 17:10:15 +02:00
▪ **TYPE**: *"weld-joint"* = 'weld-joint' as 'weld-joint'
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:90](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L90)*
2020-07-28 20:21:55 -07:00
## Methods
2021-04-16 17:10:15 +02:00
### getAnchorA
2021-05-11 18:30:36 -07:00
▸ **getAnchorA**(): *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[getAnchorA](joint.md#abstract-getanchora)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:268](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L268)*
2021-04-16 17:10:15 +02:00
Get the anchor point on bodyA in world coordinates.
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
### getAnchorB
2021-05-11 18:30:36 -07:00
▸ **getAnchorB**(): *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[getAnchorB](joint.md#abstract-getanchorb)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:275](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L275)*
2021-04-16 17:10:15 +02:00
Get the anchor point on bodyB in world coordinates.
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
### getBodyA
2021-05-11 18:30:36 -07:00
▸ **getBodyA**(): *[Body](body.md)*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[getBodyA](joint.md#getbodya)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:159](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L159)*
2021-04-16 17:10:15 +02:00
Get the first body attached to this joint.
2021-05-11 18:30:36 -07:00
**Returns:** *[Body](body.md)*
2021-04-16 17:10:15 +02:00
___
### getBodyB
2021-05-11 18:30:36 -07:00
▸ **getBodyB**(): *[Body](body.md)*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[getBodyB](joint.md#getbodyb)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:166](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L166)*
2021-04-16 17:10:15 +02:00
Get the second body attached to this joint.
2021-05-11 18:30:36 -07:00
**Returns:** *[Body](body.md)*
2021-04-16 17:10:15 +02:00
___
### getCollideConnected
▸ **getCollideConnected**(): *boolean*
*Inherited from [Joint](joint.md).[getCollideConnected](joint.md#getcollideconnected)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:190](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L190)*
2021-04-16 17:10:15 +02:00
Get collide connected. Note: modifying the collide connect flag won't work
correctly because the flag is only checked when fixture AABBs begin to
overlap.
**Returns:** *boolean*
___
2020-07-28 20:21:55 -07:00
### getDampingRatio
▸ **getDampingRatio**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:261](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L261)*
2021-04-16 17:10:15 +02:00
Get damping ratio.
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
### getFrequency
▸ **getFrequency**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:247](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L247)*
2021-04-16 17:10:15 +02:00
Get frequency in Hz.
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
### getLocalAnchorA
2021-05-11 18:30:36 -07:00
▸ **getLocalAnchorA**(): *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:219](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L219)*
2021-04-16 17:10:15 +02:00
The local anchor point relative to bodyA's origin.
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
___
### getLocalAnchorB
2021-05-11 18:30:36 -07:00
▸ **getLocalAnchorB**(): *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:226](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L226)*
2021-04-16 17:10:15 +02:00
The local anchor point relative to bodyB's origin.
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
___
### getNext
2021-05-11 18:30:36 -07:00
▸ **getNext**(): *[Joint](joint.md)*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[getNext](joint.md#getnext)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:173](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L173)*
2021-04-16 17:10:15 +02:00
Get the next joint the world joint list.
2021-05-11 18:30:36 -07:00
**Returns:** *[Joint](joint.md)*
2021-04-16 17:10:15 +02:00
___
### getReactionForce
2021-05-11 18:30:36 -07:00
▸ **getReactionForce**(`inv_dt`: number): *[Vec2](vec2.md)*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[getReactionForce](joint.md#abstract-getreactionforce)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:282](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L282)*
2021-04-16 17:10:15 +02:00
Get the reaction force on bodyB at the joint anchor in Newtons.
**Parameters:**
Name | Type |
------ | ------ |
`inv_dt` | number |
2020-07-28 20:21:55 -07:00
2021-05-11 18:30:36 -07:00
**Returns:** *[Vec2](vec2.md)*
2020-07-28 20:21:55 -07:00
___
2021-04-16 17:10:15 +02:00
### getReactionTorque
▸ **getReactionTorque**(`inv_dt`: number): *number*
*Overrides [Joint](joint.md).[getReactionTorque](joint.md#abstract-getreactiontorque)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:289](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L289)*
2021-04-16 17:10:15 +02:00
Get the reaction torque on bodyB in N*m.
**Parameters:**
Name | Type |
------ | ------ |
`inv_dt` | number |
**Returns:** *number*
___
2020-07-28 20:21:55 -07:00
### getReferenceAngle
▸ **getReferenceAngle**(): *number*
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:233](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L233)*
2021-04-16 17:10:15 +02:00
Get the reference angle.
2020-07-28 20:21:55 -07:00
**Returns:** *number*
___
2021-04-16 17:10:15 +02:00
### getType
▸ **getType**(): *string*
*Inherited from [Joint](joint.md).[getType](joint.md#gettype)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:152](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L152)*
2021-04-16 17:10:15 +02:00
Get the type of the concrete joint.
**Returns:** *string*
___
### getUserData
▸ **getUserData**(): *unknown*
*Inherited from [Joint](joint.md).[getUserData](joint.md#getuserdata)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:177](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L177)*
2021-04-16 17:10:15 +02:00
**Returns:** *unknown*
___
### initVelocityConstraints
2021-05-11 18:30:36 -07:00
▸ **initVelocityConstraints**(`step`: [TimeStep](timestep.md)): *void*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[initVelocityConstraints](joint.md#abstract-initvelocityconstraints)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:293](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L293)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`step` | [TimeStep](timestep.md) |
2021-04-16 17:10:15 +02:00
**Returns:** *void*
___
### isActive
▸ **isActive**(): *boolean*
*Inherited from [Joint](joint.md).[isActive](joint.md#isactive)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:145](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L145)*
2021-04-16 17:10:15 +02:00
Short-cut function to determine if either body is inactive.
**Returns:** *boolean*
___
2020-07-28 20:21:55 -07:00
### setDampingRatio
▸ **setDampingRatio**(`ratio`: number): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:254](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L254)*
2021-04-16 17:10:15 +02:00
Set damping ratio.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`ratio` | number |
**Returns:** *void*
___
### setFrequency
▸ **setFrequency**(`hz`: number): *void*
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:240](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L240)*
2021-04-16 17:10:15 +02:00
Set frequency in Hz.
2020-07-28 20:21:55 -07:00
**Parameters:**
Name | Type |
------ | ------ |
`hz` | number |
**Returns:** *void*
2021-04-16 17:10:15 +02:00
___
### setUserData
▸ **setUserData**(`data`: unknown): *void*
*Inherited from [Joint](joint.md).[setUserData](joint.md#setuserdata)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:181](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L181)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
`data` | unknown |
**Returns:** *void*
___
### shiftOrigin
▸ **shiftOrigin**(`newOrigin`: [Vec2](vec2.md)): *void*
2021-04-16 17:10:15 +02:00
*Inherited from [Joint](joint.md).[shiftOrigin](joint.md#shiftorigin)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/Joint.ts:217](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/Joint.ts#L217)*
2021-04-16 17:10:15 +02:00
Shift the origin for any points stored in world coordinates.
**Parameters:**
Name | Type |
------ | ------ |
`newOrigin` | [Vec2](vec2.md) |
2021-04-16 17:10:15 +02:00
**Returns:** *void*
___
### solvePositionConstraints
2021-05-11 18:30:36 -07:00
▸ **solvePositionConstraints**(`step`: [TimeStep](timestep.md)): *boolean*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[solvePositionConstraints](joint.md#abstract-solvepositionconstraints)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:463](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L463)*
2021-04-16 17:10:15 +02:00
This returns true if the position errors are within tolerance.
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`step` | [TimeStep](timestep.md) |
2021-04-16 17:10:15 +02:00
**Returns:** *boolean*
___
### solveVelocityConstraints
2021-05-11 18:30:36 -07:00
▸ **solveVelocityConstraints**(`step`: [TimeStep](timestep.md)): *void*
2021-04-16 17:10:15 +02:00
*Overrides [Joint](joint.md).[solveVelocityConstraints](joint.md#abstract-solvevelocityconstraints)*
2021-04-16 17:10:15 +02:00
2021-05-11 18:30:36 -07:00
*Defined in [src/dynamics/joint/WeldJoint.ts:399](https://github.com/shakiba/planck.js/blob/acc3bd8/src/dynamics/joint/WeldJoint.ts#L399)*
2021-04-16 17:10:15 +02:00
**Parameters:**
Name | Type |
------ | ------ |
2021-05-11 18:30:36 -07:00
`step` | [TimeStep](timestep.md) |
2021-04-16 17:10:15 +02:00
**Returns:** *void*