# Joint

class in `closed-chain-ik/core`, extends `Frame`

```js
import { Joint } from 'closed-chain-ik/core';
```

A frame representing a kinematic joint with any combination of degrees of freedom. Each
degree of freedom is an offset applied on top of the frame transform. Only links may be
added as children and a joint may only have a single child.

## Properties

### .child: Link | null

readonly

The child link of the joint, whether added directly or through `makeClosure`.

### .isClosure: boolean

readonly

Whether the child relationship is a closure made with `makeClosure`.

### .rotationDoFCount: number

readonly

Number of rotation degrees of freedom set on the joint.

### .translationDoFCount: number

readonly

Number of translation degrees of freedom set on the joint.

### .dof: Array<number>

readonly

The degrees of freedom set on the joint in `DOF` order.

### .dofFlags: Uint8Array

readonly

Flags indexed by `DOF` value that are `1` when the degree of freedom is set.

### .dofValues: Float32Array

readonly

Current values of each degree of freedom indexed by `DOF` value. If modified directly
`setMatrixDoFNeedsUpdate` must be called.

### .dofTarget: Float32Array

readonly

Target value of each degree of freedom indexed by `DOF` value. The solver moves the
joint toward these when `targetSet` is true.

### .dofRestPose: Float32Array

readonly

Rest pose of each degree of freedom indexed by `DOF` value. The solver moves the joint
toward these when `restPoseSet` is true and it does not compromise the other goals.

### .minDoFLimit: Float32Array

readonly

Minimum limit of each degree of freedom indexed by `DOF` value.

### .maxDoFLimit: Float32Array

readonly

Maximum limit of each degree of freedom indexed by `DOF` value.

### .targetSet: boolean

default `false`

Whether the solver should move the joint toward `dofTarget`.

### .restPoseSet: boolean

default `false`

Whether the solver should move the joint toward `dofRestPose`.

### .matrixDoF: Float32Array

readonly

Transform offset produced by the current degree of freedom values.

## Methods

### .clearDoF

```js
.clearDoF(  )
```

Removes all degrees of freedom from the joint.

### .setDoF

```js
.setDoF( ...dof: number )
```

Sets the degrees of freedom of the joint and resets all related values and limits.
Arguments must be in `X`, `Y`, `Z`, `EX`, `EY`, `EZ` order without duplicates.

- `dof`, `number`: The `DOF` fields to set.

### .setDoFValues

```js
.setDoFValues( ...values: number )
```

Sets the value of every degree of freedom in `dof` order, clamped to the joint limits.

- `values`, `number`: One value per degree of freedom.

### .setDoFValue

```js
.setDoFValue( dof: number, value: number ): boolean
```

Sets the value of a degree of freedom, clamped to the joint limits.

- `dof`, `number`: The `DOF` field to set.
- `value`, `number`

Returns `boolean`: Whether the value was clamped to a limit.

### .getDoFValue

```js
.getDoFValue( dof: number ): number
```

Returns the value of a degree of freedom.

- `dof`, `number`: The `DOF` field to get.

### .getDoFQuaternion

```js
.getDoFQuaternion( target: Array<number> | Float32Array )
```

Writes the rotation degree of freedom values as a quaternion into `target`.

- `target`, `Array<number> | Float32Array`

### .getDoFEuler

```js
.getDoFEuler( target: Array<number> | Float32Array )
```

Writes the rotation degree of freedom values as Euler angles into `target`.

- `target`, `Array<number> | Float32Array`

### .getDoFPosition

```js
.getDoFPosition( target: Array<number> | Float32Array )
```

Writes the translation degree of freedom values into `target`.

- `target`, `Array<number> | Float32Array`

### .setRestPoseValues

```js
.setRestPoseValues( ...values: number )
```

Sets the rest pose of every degree of freedom in `dof` order, clamped to the joint limits.

- `values`, `number`: One value per degree of freedom.

### .setRestPoseValue

```js
.setRestPoseValue( dof: number, value: number ): boolean
```

Sets the rest pose of a degree of freedom, clamped to the joint limits.

- `dof`, `number`: The `DOF` field to set.
- `value`, `number`

Returns `boolean`: Whether the value was clamped to a limit.

### .getRestPoseValue

```js
.getRestPoseValue( dof: number ): number
```

Returns the rest pose of a degree of freedom.

- `dof`, `number`: The `DOF` field to get.

### .getRestPoseQuaternion

```js
.getRestPoseQuaternion( target: Array<number> | Float32Array )
```

Writes the rotation rest pose as a quaternion into `target`.

- `target`, `Array<number> | Float32Array`

### .getRestPoseEuler

```js
.getRestPoseEuler( target: Array<number> | Float32Array )
```

Writes the rotation rest pose as Euler angles into `target`.

- `target`, `Array<number> | Float32Array`

### .getRestPosePosition

```js
.getRestPosePosition( target: Array<number> | Float32Array )
```

Writes the translation rest pose into `target`.

- `target`, `Array<number> | Float32Array`

### .setTargetValues

```js
.setTargetValues( ...values: number )
```

Sets the target of every degree of freedom in `dof` order, clamped to the joint limits.

- `values`, `number`: One value per degree of freedom.

### .setTargetValue

```js
.setTargetValue( dof: number, value: number )
```

Sets the target of a degree of freedom, clamped to the joint limits.

- `dof`, `number`: The `DOF` field to set.
- `value`, `number`

### .getTargetValue

```js
.getTargetValue( dof: number ): number
```

Returns the target of a degree of freedom.

- `dof`, `number`: The `DOF` field to get.

### .getTargetQuaternion

```js
.getTargetQuaternion( target: Array<number> | Float32Array )
```

Writes the rotation target as a quaternion into `target`.

- `target`, `Array<number> | Float32Array`

### .getTargetEuler

```js
.getTargetEuler( target: Array<number> | Float32Array )
```

Writes the rotation target as Euler angles into `target`.

- `target`, `Array<number> | Float32Array`

### .getTargetPosition

```js
.getTargetPosition( target: Array<number> | Float32Array )
```

Writes the translation target into `target`.

- `target`, `Array<number> | Float32Array`

### .setMinLimits

```js
.setMinLimits( ...values: number )
```

Sets the minimum limit of every degree of freedom in `dof` order.

- `values`, `number`: One value per degree of freedom.

### .setMinLimit

```js
.setMinLimit( dof: number, value: number )
```

Sets the minimum limit of a degree of freedom and clamps the current value to it.

- `dof`, `number`: The `DOF` field to set.
- `value`, `number`

### .getMinLimit

```js
.getMinLimit( dof: number ): number
```

Returns the minimum limit of a degree of freedom.

- `dof`, `number`: The `DOF` field to get.

### .setMaxLimits

```js
.setMaxLimits( ...values: number )
```

Sets the maximum limit of every degree of freedom in `dof` order.

- `values`, `number`: One value per degree of freedom.

### .setMaxLimit

```js
.setMaxLimit( dof: number, value: number )
```

Sets the maximum limit of a degree of freedom and clamps the current value to it.

- `dof`, `number`: The `DOF` field to set.
- `value`, `number`

### .getMaxLimit

```js
.getMaxLimit( dof: number ): number
```

Returns the maximum limit of a degree of freedom.

- `dof`, `number`: The `DOF` field to get.

### .setMatrixDoFNeedsUpdate

```js
.setMatrixDoFNeedsUpdate(  )
```

Flags the joint as needing its degree of freedom matrix and world matrix updated.

### .makeClosure

```js
.makeClosure( child: Link )
```

Connects the given link to this joint as a closure. The link is not added to `children`
and keeps its own parent, but is set as `child` and the joint is appended to the link's
`closureJoints`. The solver constrains all six axes between the joint and the link to
keep the closure closed.

- `child`, `Link`

### .addChild

```js
.addChild( child: Link )
```

Adds a link as the child of this joint. Throws if the child is not a link or the joint
already has a child.

- `child`, `Link`
