Factor Label
Factor Label is an analytic of using units to help guide conversion between different unit types.
Walkthrough: Days to Seconds
First, just start with your initial units. In this example, let's start with 1 day, and try to get to seconds.
| a | b | c | d | e | f | |
| 1 | - | - | ||||
|---|---|---|---|---|---|---|
| 2 | 1 days | -> | days | |||
| 3 |
We multiply by 24 hours per day:
| a | b | c | d | e | f | |
| 1 | - | - | - | - | - | |
|---|---|---|---|---|---|---|
| 2 | 1 |
24 hours | -> | hours | ||
| 3 | 1 |
Here we cancel out the unit "day", so we cancel it out, leaving us with a unit of Hours. But that's not seconds, so let's keep going.
| a | b | c | d | e | f | |
| 1 | - | - | - | - | - | |
|---|---|---|---|---|---|---|
| 2 | 1 |
24 |
60 minutes | -> | seconds | |
| 3 | 1 |
1 |
| a | b | c | d | e | f | |
| 1 | - | - | - | - | - | |
|---|---|---|---|---|---|---|
| 2 | 1 |
24 |
60 |
60 seconds | -> | seconds |
| 3 | 1 |
1 |
1 |
Awesome! We've now cancelled out all our units except the intended ones, and we just have a lot of numbers left over. Let's actually crunch the numbers and figure this out:
Practical Application
We'll have a lot of conversions and transformations between units in our code! This includes motor rotation -> other real world units, converting between unit types or proportions. If there's a conversion between A->B then this can be helpful. Arbitrary units like "input rotation" and "output rotation" are common ones, as is things like Gear A->Gear B.
The important part of Factor Label is that by being able to step through the dimensions, you can easily catch several common errors, such as multiplying instead of dividing, or having a "1/unit" error.
Example: KOP DriveTrain velocity
| a | b | c | d | e | f | |
| 1 | motor rev | time | gear | wheel | output | |
|---|---|---|---|---|---|---|
| 2 | 1 motor rotation | 1 min | 1 output rotation | Pi * 4 inches | -> | ?? inch |
| 3 | minute | 60 seconds | 12.75 motor rotations | 1 output rotation | s |
Example: Catching a conversion error
Let's assume we tried the above computation, and got the gearing and wheel conversions backwards.
| a | b | c | d | e | f | |
| 1 | motor rev | time | gear | wheel | output | |
|---|---|---|---|---|---|---|
| 2 | 1 motor rotation | 1 minute | 12.75 motor rotations | 1 output rotation | -> | ?? |
| 3 | minute | 60 seconds | 1 output rotation | Pi * 4 inches |
If we do our unit analysis,,,,
| a | b | c | d | e | f | |
| 1 | motor rev | time | gear | wheel | output | |
|---|---|---|---|---|---|---|
| 2 | 1 motor rotation | 1 |
12.75 motor rotations | 1 |
-> | motor rotation^2 |
| 3 | 60 seconds | 1 |
Pi * 4 inches | seconds*inches |
We can clearly see it's not right. Bug caught!