1 unit is the time it takes for a hand or prop to move from the start point to the end point of the SVGPathElement specified in CalmGenerator.prototype.paths. It moves every SVGPathElement by 1 unit, so it will move faster if the path is longer and slower if the path is shorter.
In siteswap 3, the time a prop is in the air between throws and catches is 2 units, and the time on the hand between catches and the next throw is 1 unit. It makes a parabola in the air for the first 2 units, then moves in an orbit that is CalmGenerator.prototype.offset from the hand for the next 1 unit. In siteswap 4 it is 3 units in the air, 5 is 4 units in the air, and so on.
Siteswaps 0, 1, and 2 are special. When the value is 0 or 2, the hand stops without throwing anything. The stopping position is the first point of the first SVGPathElement specified in CalmGenerator.prototype.paths. When the value is 1, a prop is thrown 0.5 units earlier than normal, travels 1 unit through the air, and is caught 0.5 units later by the opposite hand.
In order to achieve animation, it is necessary to further divide 1 unit. The number of divisions depends on the maximum value included in the siteswap (a = 10, b = 11, ..., z = 35) and the resolution specified as CalmGenerator.prototype.resolution. First, the line width is calculated, and then the number of divisions is determined.
| max value | 1-5 | 6-z |
|---|---|---|
| line width | 1 | (max value + 5) ÷ 10 |
| divisions | 12 × resolution ÷ line width | |
The line width is the same as CalmGenerator.prototype.width. Since the number of divisions must be a positive integer, any decimal places are rounded off, and values less than 1 become 1. The number of divisions when the resolution is 1 is as follows.
| max value | 1-5 | 6 | 7 | 8-9 | a-b | c-d | e-g | h-l | m-t | u-z |
|---|---|---|---|---|---|---|---|---|---|---|
| divisions | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 |
For example, for siteswap 3, 1 unit is divided into 12. In the case of 97531, the maximum value is 9, so it will be divided into 9. As the maximum value increases, the number of divisions decreases and the apparent speed increases. Because otherwise you will feel slow. You can adjust the number of divisions by changing the resolution.
The height a prop thrown into the air can reach also depends on the maximum value included in the siteswap.
| max value | 1-5 | 6 | 7 | ... | z |
|---|---|---|---|---|---|
| scale | 1 | 1.25 | 1.5 | ... | 8.5 |
| height of 1 | 15 | 12 | 10 | ... | 1.76 |
| height of 3 | 60 | 48 | 40 | ... | 7.06 |
| height of 4 | 135 | 108 | 90 | ... | 15.88 |
| height of 5 | 240 | 192 | 160 | ... | 28.24 |
| height of 6 | - | 300 | 250 | ... | 44.12 |
| height of 7 | - | - | 360 | ... | 63.53 |
| : | : | : | : | : | |
| height of z | - | - | - | ... | 2,040 |
For example, siteswap 7131 has a maximum value of 7, so among the digits it contains, the height of 7 is 360, the height of 1 is 10, and the height of 3 is 40.
The scale is the same as CalmGenerator.prototype.scale. The height of 1 is 15 ÷ scale. If 3 or greater, the height is (number - 1)2 × 15 ÷ scale. This is based on a height that uses the entire 300×300 drawing area if siteswap 5 is thrown. It is not a value calculated from gravitational acceleration.
Syntax
calculateOrbits(table, sync, throws)
Parameters
- table
- An array of throwing data. The throwing data for each prop is an object like this:
-
{ "start": 0, "length": 2, "numbers": [ 5, 1 ], "times": [ 5, 1 ], } - You can pass the return value of Siteswap.separate() as is.
- sync
- True if the throwing is synchronous, false otherwise. You can pass the sync property of the return value of Siteswap.analyze() as is.
- throws
- An array of numeric arrays representing the siteswap. You can pass the throws property of the return value of Siteswap.analyze() as is.
Return value
An object with the following properties:
- arms
- An array of arms. The size of the array is always 2 because there are 2 arms. Each element is an array of joint state lists, the size of the array is the number of joints. By default, there are two joints, the hand and the elbow, each of which has a state list.
- The joint state list is an object like this (same as the prop state list).
-
{ "init": [ pi0, pi1, pi2, ... ], "loop": [ pl0, pl1, pl2, ... ], } - The "init" is the initial action and the "loop" is the repeat action. The pi0, pl1, etc. are the coordinates to display the joints. The "init" can be an empty array.
- props
- An array of prop state lists. The size of the array is the number of props. The prop state list is an object like this (same as the joint state list).
-
{ "init": [ pi0, pi1, pi2, ... ], "loop": [ pl0, pl1, pl2, ... ], } - The "init" is the initial action and the "loop" is the repeat action. The pi0, pl1, etc. are the coordinates to display the props. The "init" can be an empty array.
Examples
const result = jmotion.Siteswap.analyze("3");
const table = jmotion.Siteswap.separate(result.throws, result.sync);
const generator = new jmotion.CalmGenerator();
const orbits = generator.calculateOrbits(table, result.sync, result.throws);
// orbits = {
// "arms": [
// [
// {
// "init": [],
// "loop": [
// { "x": -90, "y": 10 },
// { "x": -89, "y": 16 },
// ...
// ],
// },
// {
// "init": [],
// "loop": [ ... ],
// },
// ],
// [
// ...
// ],
// ],
// "props": [
// {
// "init": [],
// "loop": [
// { "x": -90, "y": 0 },
// { "x": -89, "y": 6 },
// ...
// ],
// },
// ...
// ],
// }