# Joints

<Badge tone="type">static class</Badge>

```csharp
public static class Joints
```

**Namespace:** `AR51.Unity.SDK`

The canonical **joint-index map** for the position arrays returned by [`Skeleton.GetPositions<Vector3>()`](/docs/sdk-api/unity-api/classes/skeleton) and [`Person.Positions`](/docs/sdk-api/unity-api/classes/person). Every joint is a `public const int` index into those arrays; the class also exposes name↔index lookup tables and the line/connection data used to draw skeleton gizmos. The body layout is **OpenPose-25** (indices 0–24); the hand joints follow, starting at `RightWrist = 25`.

:::note[Units]
`Joints` itself holds only **integer indices** — no spatial data. The arrays it indexes ([`Person.Positions`](/docs/sdk-api/unity-api/classes/person), `Skeleton.GetPositions<Vector3>()`) are Unity world-space `Vector3` in **meters**.
:::

## Body joint indices (OpenPose-25)

The first 25 indices are the body, in OpenPose-25 order. `CountWithoutHands` is `25`; `CountWithHands` is the full body + both hands (`= LeftPinkyTip + 1`).

```csharp
public const int CountWithoutHands = 25;
public const int CountWithHands;   // = LeftPinkyTip + 1 (full body + both hands)

// Body (OpenPose-25 layout)
public const int Nose       = 0;
public const int Neck       = 1;
public const int RShoulder  = 2;
public const int RElbow     = 3;
public const int RWrist     = 4;
public const int LShoulder  = 5;
public const int LElbow     = 6;
public const int LWrist     = 7;
public const int MidHip     = 8;
public const int RHip       = 9;
public const int RKnee      = 10;
public const int RAnkle     = 11;
public const int LHip       = 12;
public const int LKnee      = 13;
public const int LAnkle     = 14;
public const int REye       = 15;
public const int LEye       = 16;
public const int REar       = 17;
public const int LEar       = 18;
public const int LBigToe    = 19;
public const int LSmallToe  = 20;
public const int LHeel      = 21;
public const int RBigToe    = 22;
public const int RSmallToe  = 23;
public const int RHeel      = 24;

// Hip aliases (both resolve to MidHip = 8)
public const int Hip  = MidHip;
public const int Hips = MidHip;
```

## Hand joint indices

The hand joints begin immediately after the body at **`RightWrist = 25`**, then run per finger in **Proximal → Middle → Distal → Tip** order; the left hand follows the right. Each finger group is exposed twice — once with descriptive names and once with anatomical aliases:

| Descriptive | Anatomical alias |
|---|---|
| `RightIndexProximal` | `RIndex1Knuckles` |
| `RightIndexMiddle` | `RIndex2PIP` |
| `RightIndexDistal` | `RIndex3DIP` |
| `RightIndexTip` | `RIndex4FingerTip` |
| … (same pattern for thumb / middle / ring / pinky, both hands) | … |

Per-finger **offset** constants (added to a hand's wrist index to reach that finger's first joint):

```csharp
public const int ThumbOffset  = 1;
public const int IndexOffset  = 5;
public const int MiddleOffset = 9;
public const int RingOffset   = 13;
public const int PinkyOffset  = 17;
```

Spine / clavicle indices are also defined: `LClavicle`, `RClavicle`, and `Spine0`…`Spine6`.

:::caution[⚠️ Two distinct hand-joint schemes]
These body-array hand indices (`Joints`, starting `RightWrist = 25`) are **not** the same enumeration as the device hand-tracking [`HandJointType`](/docs/sdk-api/unity-api/hands-controllers-boundary#handjointtype), which indexes [`HandJointInfo[]`](/docs/sdk-api/unity-api/hands-controllers-boundary#handjointinfo) from `Wrist = 0`. Use `Joints` for the full-body skeleton arrays; use `HandJointType` for the hands-adapter arrays.
:::

## Helper data

Static tables used for drawing and grouping joints.

<div className="apiPropTable">

| Member | Type | Description |
|---|---|---|
| **Drawing** | | |
| `JointLines` | [`JointLine[]`](#jointline) | colored from→to pairs for drawing the skeleton |
| `GizmoLineConnections` | `int[][]` | bone connections used to draw the skeleton gizmo |
| **Grouped indices** | | |
| `FootJointIndices` | `int[]` | `{ LHeel, LBigToe, LSmallToe, RHeel, RBigToe, RSmallToe }` |
| `HeadJoints` | `List<int>` | `{ Nose, REye, LEye, REar, LEar }` |
| `HandWristPairs` | `int[]` | wrist-pair indices for the hands |
| `HandStrips` | `int[]` | per-finger strip indices for the hands |
| `RightLeftOffset` | `int[]` | `{ RightWrist, LeftWrist }` — base index of each hand |
| **Lookup** | | |
| `JointByString` | `Dictionary<string,int>` | name → index |
| `NameByJointIndex` | `Dictionary<int,string>` | index → name |

</div>

## Method summary

| Method | Returns | |
|---|---|---|
| [`GetJointName`](#getjointname) | `string` | <Badge>static</Badge> |
| [`Parse`](#parse) | `int` | <Badge>static</Badge> |

→ Full descriptions in [Method details](#method-details) below.

## Method details

### GetJointName

<ApiBody kind="method" tags="static">

```csharp
public static string GetJointName(int jointIndex);
```

The display name for a joint index (the reverse of [`Parse`](#parse)). Backed by `NameByJointIndex`.

<Params>
<Param name="jointIndex" type="int">a joint index (a `Joints` constant, e.g. `Joints.RWrist`)</Param>
</Params>

<Returns type="string">the joint's name (e.g. `"RWrist"`)</Returns>

<Example inferred>

```csharp
foreach (var person in SkeletonConsumer.Instance.Persons)
{
    Vector3 head = person.GetPosition(Joints.Nose);   // meters
    Debug.Log($"{Joints.GetJointName(Joints.Nose)} at {head}");
}
```

</Example>

</ApiBody>

### Parse

<ApiBody kind="method" tags="static">

```csharp
public static int Parse(string s);
```

Resolve a joint **name** to its index (the reverse of [`GetJointName`](#getjointname)). Backed by `JointByString`.

<Params>
<Param name="s" type="string">a joint name (e.g. `"RWrist"`)</Param>
</Params>

<Returns type="int">the matching joint index, or `-1` if the name is unknown</Returns>

</ApiBody>

## Nested types

### JointLine

<ApiBody kind="property">

```csharp
public struct JointLine
{
    public int From;
    public int To;
    public Color Color;
    public JointLine(int from, int to, Color color);
}
```

A single colored bone segment: two joint indices and the [`Color`](https://docs.unity3d.com/ScriptReference/Color.html) to draw it in. The [`JointLines`](#helper-data) table is an array of these, consumed by the skeleton-drawing helpers.

</ApiBody>

## HandJoints

<Badge tone="type">sealed class</Badge> <Badge>Unity component</Badge>

```csharp
public sealed class HandJoints : MonoBehaviour
```

**Namespace:** `AR51.Unity.SDK`

A `MonoBehaviour` **marker component** placed on a hand-joint hierarchy. It is a separate type from the static `Joints` index map above.

:::caution[⚠️ needs confirmation]
`HandJoints` has an **empty body — no public members** in this version; it appears to exist only as a tag/marker on a hand-joint hierarchy. Confirm its intended role before relying on it.
:::

## See also

- [`Skeleton`](/docs/sdk-api/unity-api/classes/skeleton) — the per-frame payload whose `GetPositions<Vector3>()` buffer these indices address
- [`Person`](/docs/sdk-api/unity-api/classes/person) — exposes `Positions` / `GetPosition(int)` indexed by these constants
- [`HandJointType`](/docs/sdk-api/unity-api/hands-controllers-boundary#handjointtype) — the **separate** device hand-tracking joint enumeration (`Wrist = 0`)
- [Skeletons & characters](/docs/sdk-api/unity-api/skeletons-and-characters) — area overview
- [Class index](/docs/sdk-api/unity-api/classes) — all Unity SDK types
