2021-05-11 18:30:36 -07:00

448 lines
11 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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