# Cogwheel

### **UI**

**Teeth** - set the number of teeth or cogs.

**Pitch Radius** - set the radius from the centre to the midpoint of the tooth.

**Hole Radius** - set the radius of the hole.

**Tooth Depth** - set a value for the total height of the teeth.

**Tooth Width** - set the width of the tooth at its midpoint.

**Tooth Taper** - set the inner and outer taper angles for the teeth.

**Midpoint Position** - set the midpoint of the Teeth from 0 - 1. 0 is the base of the tooth and 1 is the tip.

### Gear Example

<div align="center"><img src="https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-M7Hs61KOcy8T_Yt292l%2F-M7Hti3FxmyoFJXQ3XgI%2Fcogwheel.png?alt=media&#x26;token=3a3503e2-248f-4557-a78e-c2767738ff66" alt="All rotation is driven by the medium Cogwheel."></div>

In order to create a gear system there are some basic guides to follow:

* The **Module** of each Cogwheel must match. The module is a ratio which can be easily expressed as:
  * **pitch diameter / the number of teeth**.\
    Or in Cavalry's case:
  * 2 \* **Pitch Radius** / **Teeth.**
* The teeth must be the same shape/size.
* The **Pitch Circle** of one Cogwheel must 'touch' the other.

In the example below:

* the **Medium** Cogwheel has a **Pitch Radius** of **200** and **12** **Teeth.**
* the **Small** Cogwheel has a **Pitch Radius** of **100** and **6** **Teeth.**
* the **Large** Cogwheel has a **Pitch Radius** of **400** and **24** **Teeth.**

**`200 / 12`**, **`100 / 6`** and **`400 / 24`** all equal **`16.66`** so each Cogwheel has the same **Module**.

The math for the rotation is also quite simple. If:

* **r1** = Rotation of the Medium Cogwheel
* **t1** = Number of Teeth of the Medium Cogwheel
* **r2** = Rotation of the Small Cogwheel
* **t2** = Number of Teeth of the Small Cogwheel

$$r2 = r1 \* t1 / t2$$

so in the case of **Medium** > **Small** that would be:

$$r2 = r1 \* 12/6$$&#x20;

You can use a [Jsmath](https://scenegroup.gitbook.io/cavalry/nodes/utilities/js-math) Atom to rig this equation up.

1. Create a [Jsmath](https://scenegroup.gitbook.io/cavalry/nodes/utilities/js-math) Atom.
2. Add 3 indices.
3. Connect ***Medium.rotation > jsmath.index0***
4. Connect ***Medium.teeth > jsmath.index1***
5. Connect ***Small.teeth > jsmath.index2***
6. Connect ***jsmath.id > Small.rotation***

As you rotate the **Medium** Cogwheel, the **Small** Cogwheel will rotate at the correct speed to mesh. In order to position them correctly you'll need to move them 300 apart in X (the total of their Pitch Radius values).

{% file src="<https://1676825895-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LT2-S1m8aSPAI_Gg3Q1%2F-M7I8kZlPvCHBiwPmNTe%2F-M7I951LcTT9Y9zqqfy6%2FgearSystem.cv.zip?alt=media&token=ef284814-c349-4057-b64f-2e77c0b079f2>" %}
Gear System Example
{% endfile %}
