BasicCreator.prototype.calculateOrbits()
The calculateOrbits() method calculates right and left arm movements and prop orbits based on throwing data.
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 BasicCreator.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 palm 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 BasicCreator.prototype.offset from the palm 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 2 and 1 are special. If it is 2, a prop will not throw and will always move on the orbit (offset away from the palm). If it is 1, a prop will throw 0.5 units earlier than normal, will move 1 unit through the air, and will catch 0.5 units later in the opposite palm.
In order to achieve animation, it is necessary to further divide 1 unit, and the number of divisions depends on the maximum value included in the siteswap (a = 10, b = 11, ..., z = 35).
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.
The method for calculating the number of divisions is as follows. First, let siteswap 5 have 12 divisions and speed 1, and siteswap 4 and below are the same as 5. Next, for siteswap 6 or greater, increase the speed by 0.1 in increments of 1, divide 12 by the speed, and then round off to find the number of divisions.
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.
First calculate the scale as shown in the getScale() method, then find the height of each number. 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)
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.
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 palm 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. The size of the "loop" array is the number of SVGPathElements for that joint multiplied by the number of divisions.
- 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. The size of the "loop" array is the sum of the height (absolute value) for one cycle contained in the argument throwing data, multiplied by the number of divisions.
Examples
const result = jmotion.Siteswap.analyze("3");
const table = jmotion.Siteswap.separate(result.throws, result.sync);
const creator = new jmotion.BasicCreator();
const orbits = creator.calculateOrbits(table, result.sync);
// 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 },
// ...
// ],
// },
// ...
// ],
// }