Siteswap.separate()
The separate() method analyzes siteswap data and returns throwing data for each prop. For example, if the siteswap is 531, three props A, B, and C are thrown as shown in the table below.
time | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
---|---|---|---|---|---|---|---|---|---|---|---|---|
right | A | C | B | A | C | B | ||||||
left | B | C | A | B | C | A |
Now, looking at each prop, we can see:
- The first time A was thrown is 0, and the throwing pattern is 5-1-5-1-... in order.
- The first time B was thrown is 1, and the throwing pattern is 3-3-3-3-... in order.
- The first time C was thrown is 2, and the throwing pattern is 1-5-1-5-... in order.
These are the "throwing data for each prop".
Syntax
separate(throws, sync)
Parameters
- throws
- An array of numeric arrays representing the siteswap. You can pass the throws property of the return value of analyze() as is.
- sync
- True if the siteswap is synchronous, false otherwise. You can pass the sync property of the return value of analyze() as is.
Return value
An array of objects with the following properties, where the size of the array is the number of props.
- length
- The length of period for the siteswap. It represents the number of throws from the first time the prop is thrown until it returns to the same state with the same hand. This matches the size of the numbers and the times properties.
- numbers
- An array of integers representing the throw heights for the period. For synchronous, it has a minus instead of x. For example, 4x is -4.
- start
- An integer greater than or equal to 0 representing the time of the first throw.
- times
- An array of integers greater than or equal to 1 representing the throw times for the period. For synchronous, numbers with x are converted to odd numbers, where +1 is added to the left number and -1 to the right number. For example, (4x,2x) becomes 5 for 4x and 1 for 2x. Otherwise, it will be the same as the value of the numbers property.
Examples
const result = jmotion.Siteswap.analyze("(4x,2x)");
const table = jmotion.Siteswap.separate(result.throws, result.sync);
// table = [
// {
// "length": 2,
// "numbers": [-4, -2],
// "start": 0,
// "times": [5, 1],
// },
// {
// "length": 2,
// "numbers": [-2, -4],
// "start": 1,
// "times": [1, 5],
// },
// {
// "length": 2,
// "numbers": [-2, -4],
// "start": 3,
// "times": [1, 5],
// },
// ]