# Discussion of all possible constraint combinations

**URL:** <https://forum.babylonjs.com/t/discussion-of-all-possible-constraint-combinations/54079>\
**Category:** Questions\
**Created:** [October 12, 2024, 3:12am UTC](https://forum.babylonjs.com/t/discussion-of-all-possible-constraint-combinations/54079 "2024-10-12T03:12:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![HiGreg](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@HiGreg](https://forum.babylonjs.com/u/HiGreg)\
**Post date:** [October 12, 2024, 3:12am UTC](https://forum.babylonjs.com/t/discussion-of-all-possible-constraint-combinations/54079/1 "2024-10-12T03:12:22Z")

</div>

I’m trying to wrap my head around Physics Constraints. I hope this starts a discussion we all can learn from. I think there are 20 possible constraint types, including LOCK and 6DOF. This boils down to 18 interesting ones. BABYLON/Havok only names 5 of these 18. The following table shows all possible combinations of locked degrees of freedom. From two other sources, documentation from [COMSOL](https://doc.comsol.com/5.5/doc/com.comsol.help.mbd/mbd_ug_modeling.3.07.html), and a [2005 academic paper](https://asmedigitalcollection.asme.org/IDETC-CIE/proceedings-abstract/IDETC-CIE2005/47438/1733/317126). COMSOL has some nice pictures and pretty detailed explanations linked from their page.

The left column “DIDACTIC” is the name given by the paper, the second column is BABYLON/Havok’s name, and (in lowercase) the name from COMSOL. Duplicatecor alternate COMSOL names are not shown.

| DIDACTIC | Babylon/Havok (comsol) | Lx | Ly | Lz | Ax | Ay | Az | DoF |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| | LOCK | ⬤ | ⬤ | ⬤ | ⬤ | ⬤ | ⬤ | 0 |
| | | | | | | | | |
| revolute | HINGE | ⬤ | ⬤ | ⬤ | | ⬤ | ⬤ | 1 |
| prismatic | PRISMATIC | | ⬤ | ⬤ | ⬤ | ⬤ | ⬤ | 1 |
| | | | | | | | | |
| | | | | ⬤ | ⬤ | ⬤ | ⬤ | 2 |
| slotted spheric vs. toric? | universal | ⬤ | ⬤ | ⬤ | | | ⬤ | 2 |
| cylindrical | SLIDER | | ⬤ | ⬤ | | ⬤ | ⬤ | 2 |
| slotted-cylindric? | reduced slot | | ⬤ | ⬤ | ⬤ | | ⬤ | 2 |
| | | | | | | | | |
| | | | | | ⬤ | ⬤ | ⬤ | 3 |
| spheric | BALL\_AND\_SOCKET | ⬤ | ⬤ | ⬤ | | | | 3 |
| | | | | ⬤ | | ⬤ | ⬤ | 3 |
| planar? | planar | | | ⬤ | ⬤ | ⬤ | | 3 |
| | | | ⬤ | ⬤ | | ⬤ | | 3 |
| sphere-slotted cylinder | | | ⬤ | ⬤ | ⬤ | | | 3 |
| | | | | | | | | |
| cylinder-plane | | | | ⬤ | | | ⬤ | 4 |
| | | | | ⬤ | | ⬤ | | 4 |
| | | | | | | ⬤ | ⬤ | 4 |
| sphere-groove | slot | | ⬤ | ⬤ | | | | 4 |
| | | | | | | | | |
| sphere-plane | | | | ⬤ | | | | 5 |
| | | | | | | | ⬤ | 5 |
| | | | | | | | | |
| | 6DOF | | | | | | | 6 |

 ![Notes_241011_225739_1f3](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/1/7/17957c7c05743f40da471bff597103eb2f4ee09e.jpeg)  
(Image from “DETC2005-84109 ON THE COMPUTATION OF DEGREES-OF-FREEDOM : A DIDACTIC PERSPECTIVE” by E. Pennestrì, M. Cavacece, L. Vita, Published 2005.

Interestingly, there are two different names/implementations of 2 angular degrees of freedom in the paper: slotted spheric and toric. What’s the difference in these?

I’m trying to create a playground to help my understanding. In the meantime, there’s these two:

- Constraints: [Babylon.js Playground](https://playground.babylonjs.com/#7DMWP8)
- 6DOF Joint Tool: [Babylon.js Playground](https://playground.babylonjs.com/#RMF5CJ)

---

<div class="post-metadata">

**Author:** ![regna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/regna/32/23915_2.png) [@regna](https://forum.babylonjs.com/u/regna)\
**Post date:** [October 12, 2024, 4:44pm UTC](https://forum.babylonjs.com/t/discussion-of-all-possible-constraint-combinations/54079/2 "2024-10-12T16:44:10Z")

</div>

Wow, there are so many joint types I didn’t know about 😮 Thank you for the detailed list!

A small addition: For spheric/ball-and-socket joints, there are twist (e.g. X) and swing (Y and Z) angles. If you want limits for the 2 swing angles, the limits can have a cone or pyramid shape.

I don’t have a good image for this - the best I could find online is [https://scaron.info/images/friction-cones.png](https://scaron.info/images/friction-cones.png). I should be able to take a video of these 2 limit shapes and share it in [your post](https://forum.babylonjs.com/t/seeking-feedback-on-havok-physics-visualizations-for-debug/53749/10) today

---

<div class="post-metadata">

**Author:** ![HiGreg](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@HiGreg](https://forum.babylonjs.com/u/HiGreg)\
**Post date:** [October 12, 2024, 5:17pm UTC](https://forum.babylonjs.com/t/discussion-of-all-possible-constraint-combinations/54079/3 "2024-10-12T17:17:37Z")

</div>

Interesting. I left out definitions of limits because I wanted to focus on joint attachments only. Are any of these joints fundamentally altered by limits?

I think Havok only natively implements pyramid-shaped, right? Calculated interdependent limits would be interesting. Or maybe distance from a line in addition to distance from a point.

Hmmm. Maybe could combine phantom objects and distance joints to construct different limit “types.”

---

<div class="post-metadata">

**Author:** ![regna](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/regna/32/23915_2.png) [@regna](https://forum.babylonjs.com/u/regna)\
**Post date:** [October 12, 2024, 5:47pm UTC](https://forum.babylonjs.com/t/discussion-of-all-possible-constraint-combinations/54079/4 "2024-10-12T17:47:27Z")

</div>

> [@HiGreg](#):
>
> I left out definitions of limits because I wanted to focus on joint attachments only. Are any of these joints fundamentally altered by limits?

Got it! The joints shouldn’t be fundamentally altered by limits.

> [@HiGreg](#):
>
> I think Havok only natively implements pyramid-shaped, right?

You’re right in that the public Havok API we have access to only has the pyramid limit. Maybe the full Havok source has the cone limit.

---

<div class="post-metadata">

**Author:** ![HiGreg](https://avatars.discourse-cdn.com/v4/letter/h/c5a1d2/32.png) [@HiGreg](https://forum.babylonjs.com/u/HiGreg)\
**Post date:** [October 13, 2024, 11:21am UTC](https://forum.babylonjs.com/t/discussion-of-all-possible-constraint-combinations/54079/5 "2024-10-13T11:21:02Z")

</div>

Edit 3: Here’s the best demo: tap to impart force. All combinations shown:

> **[Babylon.js Playground](https://playground.babylonjs.com/#O8FSDA%236)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

Here are my previous attempts:  
/end Edit3.

Tool to play with any combination of LOCKED Axes is now in the playground. Change one line of code (line 99) to enable/disable axis locks. Tap the screen to impart a random force on the yellow box.

> **[Babylon.js Playground](https://playground.babylonjs.com/#O8FSDA%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

Edit: here’s a full array of all constraint “types”. I’m having trouble with setting a joint’s limits after creation, so there are no linear limits here. Touch the screen to impart a force.

> **[Babylon.js Playground](https://playground.babylonjs.com/#O8FSDA%233)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

I’m not totally sure this is useful, yet. But it does demonstrate how to change an axisMode between LOCK and FREE after constraint creation.

Edit 2: Here’s a better one where the initial offset of the yellow box is diagonal. It shows how locking a particular linear axis aligns those axes between parent and child (i.e. aligning the defined axis’, perps, or normals of both bodies).

> **[Babylon.js Playground](https://playground.babylonjs.com/#O8FSDA%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes
