clumsy-math
a little library of helpful math utensils
documentation
rhythm (concepts)
rhythm slot
a rhythm's building block
const rhythm = [true, true, false, true, false];
const rhythmSlotZero = true; // rhythm[0]
const rhythmSlotTwo = false; // rhythm[2]
rhythm resolution
the number of slots that make up a rhythm
const rhythm = [true, true, false, true, false];
const rhythmResolution = 5; // rhythm.length
rhythm point
the index of a slot whose value is true/1
const rhythm = [true, true, false, true, false];
const rhythmPoints = [0, 1, 3];
rhythm density
the number of points in a rhythm
const rhythm = [true, true, false, true, false];
const rhythmPoints = [0, 1, 3];
const rhythmDensity = 3; // rhythmPoints.length
rhythm phase
an offset measured in slots applied to points relative to a base rhythm
const rhythm = [true, true, false, true, false];
const rhythmPhase = -1;
const phasedRhythm = [false, true, true, false, true];
rhythm orientation
the point index relative to a base rhythm that indicates a reoriented rhythm's anchor/starting point
const rhythm = [true, true, false, true, false];
const reorientedRhythm = [true, false, true, false, true];
const reorientedRhythmOrientation = 1;
rhythm point, rhythm resolution
relative rhythm point
a point whose value is normalized within the range of [0, 1)
const rhythm = [true, true, false, true, false];
const rhythmPoints = [0, 1, 3];
const relativeRhythmPoints = [0, 0.2, 0.6];
rhythm point, rhythm resolution
rhythm interval
the length/distance between two points measured in slots
const rhythm = [true, true, false, true, false];
const rhythmPoints = [0, 1, 3];
const rhythmIntervals = [1, 2, 2];
rhythm
a discrete sequence/cycle of binary values
const rhythm = [true, true, false, true, false];
white paper
euclidean rhythm -a rhythm who's points are as evenly distributed as possible throughout a discrete space
const rhythmAaa = [true, false, true, false];
const rhythmBbb = [true, true, false, true, false];
const rhythmCcc = [true, false, true, false, true];
recursive euclidean rhythm
a rhythm composed by stacking euclidean rhythms on top of each other where the base rhythm's density/points determines the next rhythm's resolution/space
const baseRhythm = [true, true, false, true, false];
const terminalRhythm = [true, false, true];
const resultRhythm = [true, false, false, true, false];
rhythm component, euclidean rhythm, rhythm point, rhythm resolution
aligned recursive euclidean rhythm
a recursive euclidean rhythm where rhythm layers have a phase of zero such that one of it's points remains anchored to the zero slot
const baseRhythm = [true, true, false, true, false];
const terminalRhythm = [true, false, true];
const resultRhythm = [true, false, false, true, false];
recursive euclidean rhythm, rhythm slot, rhythm phase
AlignedRecursiveEuclideanRhythm, AlignedRecursiveEuclideanRhythmId
getAlignedRhythmId, getAlignedRhythmComponents
phased recursive euclidean rhythm
a recursive euclidean rhythm where rhythm layers can be phased
const baseRhythm = [true, true, false, true, false];
const terminalRhythm = [false, true, true]; // phase === -1
const resultRhythm = [false, true, false, true, false];
recursive euclidean rhythm, rhythm phase
rhythm component
a recursive euclidean rhythm of a recursive euclidean rhythm
const terminalComponentRhythm = [true, false, false, false, true, false, false];
const interposedComponentRhythm = [true, true, false, false, true, false, false];
const initialComponentRhythm = [true, true, true, false, true, true, false];
PhasedRhythmComponent, AlignedRhythmComponent
getPhasedRhythmComponents, getAlignedRhythmComponents
rhythm group
a set of recursive euclidean rhythms that share a static base structure and a dynamic member structure where the density structure is the same but orientations are different
const groupBaseRhythm = [true, true, false, true, false];
const memberRhythmBase = [true, true, false];
const memberBaseRhythmAaa = [true, true, false]; // memberRhythmBase with orientation 0
const memberBaseRhythmBbb = [true, false, true]; // memberRhythmBase with orientation 1
const groupMemberRhythmAaa = [true, true, false, false, false]; // 11010 -> 110 === 11000
const groupMemberRhythmBbb = [true, false, false, true, false]; // 11010 -> 101 === 10010
RhythmGroup, RhythmGroupStructure, RhythmGroupId
getRhythmGroup, getRhythmGroupId, getRhythmLineage
rhythm lineage
all rhythm groups an aligned recursive euclidean rhythm belongs to
const rhythm = [true, false, false, true, false];
const rhythmLineage = [
[
[true, true, false, false, false],
[true, false, false, true, false],
[true, false, true, false, false],
[true, false, false, false, true],
[true, false, true, false, false],
[true, false, false, true, false],
],
[
[true, true, false, false, false],
[true, false, false, true, false],
],
];
rhythm group, aligned recursive euclidean rhythm
rhythm slot weight
the number/count of points that exist at a slot in the context of a set of rhythms which all have the same resolution
const rhythmAaa = [true, true, false, true, false]; // 1, 1, 0, 1, 0
const rhythmBbb = [true, false, true, false, true]; // 1, 0, 1, 0, 1
const rhythmCcc = [true, false, true, true, false]; // 1, 0, 1, 1, 0
const rhythmSlotWeights = [3, 1, 2, 2, 1];
const rhythmSlotWeightZero = 3; // rhythmSlotWeights[0]
RhythmSlotWeight, RhythmPointWeight, RhythmWeight
getRhythmSlotWeights, getRhythmPointWeights, getRhythmWeight
rhythm point weight
a point's corresponding slot weight
const rhythmAaa = [true, true, false, true, false];
const rhythmBbb = [true, false, true, false, true];
const rhythmCcc = [true, false, true, true, false];
const rhythmSlotWeights = [3, 1, 2, 2, 1];
const rhythmAaaPoints = [0, 1, 3];
const rhythmAaaPointZeroWeight = 3; // rhythmSlotWeights[rhythmAaaPoints[0]]
rhythm slot weight, rhythm point
rhythm weight
the sum of a rhythm's point weights
const rhythmAaa = [true, true, false, true, false];
const rhythmBbb = [true, false, true, false, true];
const rhythmCcc = [true, false, true, true, false];
const rhythmSlotWeights = [3, 1, 2, 2, 1];
const rhythmAaaPoints = [0, 1, 3];
const rhythmAaaWeight = 6;
rhythm point weight, rhythm point
rhythm (encodings)
RhythmSlot
rhythm slot as boolean
RhythmResolution
rhythm resolution as number
RhythmDensity
rhythm density as number
RhythmPoint
rhythm point as number
RelativeRhythmPoint
relative rhythm point as number
RhythmInterval
rhythm interval as number
RhythmPhase
rhythm phase as number
RhythmOrientation
rhythm orientation as number
Rhythm
rhythm as Array<RhythmSlot>
const rhythm: Rhythm = [true, true, false, true, false];
RhythmString
rhythm as binary string
const rhythmString: RhythmString = "11010";
RhythmMap
the defacto encoding for Rhythm
const rhythmMap: RhythmMap = {
rhythmResolution: 5,
rhythmPoints: [0, 1, 3],
};
rhythm resolution, rhythm point
getRhythmMap, getRhythmString, getPhasedRhythmMap, getRelativeRhythmPoints, getRhythmSlotWeights, getRhythmPointWeights, getRhythmWeight
EuclideanRhythm
euclidean rhythm as Rhythm
SimpleRhythmStructure
minimal encoding for EuclideanRhythm
const simpleRhythmStructure: SimpleRhythmStructure = {
rhythmResolution: 5,
rhythmDensity: 3,
};
euclidean rhythm, rhythm resolution, rhythm density
GeneralRhythmStructure
generalized encoding for EuclideanRhythm
const generalRhythmStructure: GeneralRhythmStructure = {
rhythmResolution: 5,
rhythmDensity: 3,
rhythmOrientation: 0,
rhythmPhase: 0,
};
euclidean rhythm, rhythm resolution, rhythm density, rhythm orientation, rhythm phase
RecursiveEuclideanRhythm
recursive euclidean rhythm as Rhythm
RecursiveRhythmStructure
foundational encoding for RecursiveEuclideanRhythm
getRhythmMap, getStackRhythmStructure
StackRhythmStructure
utilitarian encoding that encompasses both AlignedRhythmStructure and PhasedRhythmStructure
const stackRhythmStructure: StackRhythmStructure = [
{
rhythmResolution: 5,
rhythmDensity: 3,
rhythmOrientation: 0,
rhythmPhase: 0,
},
{
rhythmResolution: 3,
rhythmDensity: 2,
rhythmOrientation: 0,
rhythmPhase: 0,
},
];
aligned recursive euclidean rhythm, phased recursive euclidean rhythm
AlignedRecursiveEuclideanRhythm
aligned recursive euclidean rhythm as RecursiveEuclideanRhythm
aligned recursive euclidean rhythm
AlignedRhythmStructure
a human-centric encoding for AlignedRecursiveEuclideanRhythm
const alignedRhythmStructure: AlignedRhythmStructure = {
structureType: "initial",
rhythmResolution: 5,
subStructure: {
structureType: "interposed",
rhythmDensity: 3,
rhythmOrientation: 0,
subStructure: {
structureType: "terminal",
rhythmDensity: 2,
rhythmOrientation: 0,
},
},
};
aligned recursive euclidean rhythm
getRhythmMap, getAlignedRhythmId, getRhythmLineage
AlignedRecursiveEuclideanRhythmId
aligned recursive euclidean rhythm as string
aligned recursive euclidean rhythm
AlignedRhythmComponent
aligned rhythm component as AlignedRhythmStructure
PhasedRecursiveEuclideanRhythm
phased recursive euclidean rhythm as RecursiveEuclideanRhythm
phased recursive euclidean rhythm
PhasedRhythmStructure
a human-centric encoding for PhasedRecursiveEuclideanRhythm
const phasedRhythmStructure: PhasedRhythmStructure = {
structureType: "initial",
rhythmResolution: 5,
rhythmPhase: 0,
subStructure: {
structureType: "interposed",
rhythmDensity: 3,
rhythmOrientation: 0,
rhythmPhase: 0,
subStructure: {
structureType: "terminal",
rhythmDensity: 2,
rhythmOrientation: 0,
},
},
};
phased recursive euclidean rhythm
PhasedRecursiveEuclideanRhythmId
phased recursive euclidean rhythm as string
phased recursive euclidean rhythm
PhasedRhythmComponent
phased rhythm component as PhasedRhythmStructure
RhythmGroup
rhythm group as Array<AlignedRecursiveEuclideanRhythm>
rhythm group, aligned recursive euclidean rhythm
RhythmGroupStructure
compact encoding for RhythmGroup
const rhythmGroupStructure: RhythmGroupStructure = {
baseStructure: {
structureType: "initial",
rhythmResolution: 5,
},
memberStructure: {
structureType: "terminal",
rhythmDensity: 3,
},
};
getRhythmGroup, getRhythmGroupId
RhythmGroupId
rhythm group as string
RhythmLineage
rhythm lineage as Array<RhythmGroupStructure>
RhythmSlotWeight
rhythm slot weight as number
getRhythmSlotWeights, getRhythmPointWeights, getRhythmWeight
RhythmPointWeight
rhythm point weight as number
RhythmWeight
rhythm weight as number
getRhythmWeight, getRhythmWeight
rhythm (functions)
getSimpleRhythm
transforms SimpleRhythmStructure to Rhythm
const simpleRhythm = getSimpleRhythm({
rhythmResolution: 5,
rhythmDensity: 3,
});
// simpleRhythm === [true,true,false,true,false]
getStackRhythmStructure
transforms RecursiveRhythmStructure to StackRhythmStructure
const stackRhythmStructure = getStackRhythmStructure({
structureType: "initial",
rhythmResolution: 5,
subStructure: {
structureType: "interposed",
rhythmDensity: 3,
rhythmOrientation: 0,
subStructure: {
structureType: "terminal",
rhythmDensity: 2,
rhythmOrientation: 0,
},
},
});
// stackRhythmStructure ===
// [
// {
// rhythmResolution: 5,
// rhythmDensity: 3,
// rhythmOrientation: 0,
// rhythmPhase: 0,
// },
// {
// rhythmResolution: 3,
// rhythmDensity: 2,
// rhythmOrientation: 0,
// rhythmPhase: 0,
// },
// ];
getPhasedRhythmMap
computes RhythmMap from RhythmMap and RhythmPhase
const phasedRhythmMap = getPhasedRhythmMap(
getRhythmMap({
structureType: "initial",
rhythmResolution: 5,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
}),
-1
);
// phasedRhythmMap ===
// {
// rhythmResolution: 5,
// rhythmPoints: [1, 2, 4],
// };
getRelativeRhythmPoints
transforms RhythmMap to Array<RelativeRhythmPoint>
const relativeRhythmPoints = getRelativeRhythmPoints(
getRhythmMap({
structureType: "initial",
rhythmResolution: 5,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
})
);
// relativeRhythmPoints === [0, 0.2, 0.6];
getPhasedRhythmComponents
computes Array<PhaseRhythmComponent> from PhasedRhythmStructure
const phasedRhythmComponents = getPhasedRhythmComponents({
structureType: "initial",
rhythmResolution: 7,
rhythmPhase: 0,
subStructure: {
structureType: "interposed",
rhythmDensity: 5,
rhythmOrientation: 0,
rhythmPhase: 0,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
},
});
// phasedRhythmComponents ===
// [
// {
// structureType: "initial",
// rhythmResolution: 7,
// rhythmPhase: 0,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 5,
// rhythmOrientation: 0,
// },
// },
// {
// structureType: "initial",
// rhythmResolution: 7,
// rhythmPhase: 0,
// subStructure: {
// structureType: "interposed",
// rhythmDensity: 5,
// rhythmOrientation: 0,
// rhythmPhase: 0,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 3,
// rhythmOrientation: 0,
// },
// },
// },
// ];
rhythm component, phased recursive euclidean rhythm
getAlignedRhythmComponents
computes Array<AlignedRhythmComponent> from AlignedRhythmStructure
const alignedRhythmComponents = getAlignedRhythmComponents({
structureType: "initial",
rhythmResolution: 7,
subStructure: {
structureType: "interposed",
rhythmDensity: 5,
rhythmOrientation: 0,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
},
});
// alignedRhythmComponents ===
// [
// {
// structureType: "initial",
// rhythmResolution: 7,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 5,
// rhythmOrientation: 0,
// },
// },
// {
// structureType: "initial",
// rhythmResolution: 7,
// subStructure: {
// structureType: "interposed",
// rhythmDensity: 5,
// rhythmOrientation: 0,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 3,
// rhythmOrientation: 0,
// },
// },
// },
// ];
rhythm component, aligned recursive euclidean rhythm
getRhythmGroupId
transforms RhythmGroupStructure to RhythmGroupId
const rhythmGroupId = getRhythmGroupId({
baseStructure: {
structureType: "initial",
rhythmResolution: 5,
},
memberStructure: {
structureType: "terminal",
rhythmDensity: 3,
},
});
// rhythmGroupId === "group___5___3";
getRhythmGroup
transforms RhythmGroupStructure to RhythmGroup
const rhythmGroup = getRhythmGroup({
baseStructure: {
structureType: "initial",
rhythmResolution: 5,
},
memberStructure: {
structureType: "terminal",
rhythmDensity: 3,
},
});
// rhythmGroup ===
// [
// {
// structureType: "initial",
// rhythmResolution: 5,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 3,
// rhythmOrientation: 0,
// },
// },
// {
// structureType: "initial",
// rhythmResolution: 5,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 3,
// rhythmOrientation: 1,
// },
// },
// {
// structureType: "initial",
// rhythmResolution: 5,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 3,
// rhythmOrientation: 2,
// },
// },
// ];
getAlignedRhythmId
transforms AlignedRhythmStructure to AlignedRecursiveEuclideanRhythmId
const alignedRhythmId = getAlignedRhythmId({
structureType: "initial",
rhythmResolution: 5,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
});
// alignedRhythmId === "aligned__5__3_0"
aligned recursive euclidean rhythm
getPhasedRhythmId
transforms PhasedRhythmStructure to PhasedRecursiveEuclideanRhythmId
const phasedRhythmId = getPhasedRhythmId({
structureType: "initial",
rhythmResolution: 5,
rhythmPhase: 0,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
});
// phasedRhythmId === "phased__5_0__3_0"
phased recursive euclidean rhythm
getRhythmIntervals
computes Array<RhythmInterval> from RhythmMap
const rhythmIntervals = getRhythmIntervals(
getRhythmMap({
structureType: "initial",
rhythmResolution: 5,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
})
);
// rhythmIntervals = [1,2,2]
getRhythmLineage
computes RhythmLineage from AlignedRhythmStructure
const rhythmLineage = getRhythmLineage({
structureType: "initial",
rhythmResolution: 7,
subStructure: {
structureType: "interposed",
rhythmDensity: 5,
rhythmOrientation: 0,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
},
});
// rhythmLineage ===
// [
// {
// baseStructure: {
// structureType: "initial",
// rhythmResolution: 7,
// },
// memberStructure: {
// structureType: "interposed",
// rhythmDensity: 5,
// subStructure: {
// structureType: "terminal",
// rhythmDensity: 3,
// },
// },
// },
// {
// baseStructure: {
// structureType: "initial",
// rhythmResolution: 7,
// subStructure: {
// structureType: "interposed",
// rhythmDensity: 5,
// rhythmOrientation: 0,
// },
// },
// memberStructure: {
// structureType: "terminal",
// rhythmDensity: 3,
// },
// },
// ];
getRhythmMap
transforms RecursiveRhythmStructure to RhythmMap
const rhythmMap = getRhythmMap({
structureType: 'initial',
rhythmResolution: 5,
subStructure: {
structureType: 'terminal'
rhythmDensity: 3,
rhythmOrientation: 0
}
})
// rhythmMap === {
// rhythmResolution: 5,
// rhythmPoints: [0,1,3]
// }
rhythm resolution, rhythm point
getRhythmPointWeights
computes Array<RhythmPointWeight> from RhythmMap and Array<RhythmSlotWeight>
const rhythmGroupRhythmMaps = getRhythmGroup({
baseStructure: {
structureType: "initial",
rhythmResolution: 5,
},
memberStructure: {
structureType: "terminal",
rhythmDensity: 3,
},
}).map(getRhythmMap);
const rhythmPointWeights = getRhythmPointWeights(
rhythmGroupMemberRhythmMaps[0],
getRhythmSlotWeights(rhythmGroupMemberRhythmMaps)
);
// rhythmPointWeights === [3, 1, 2];
rhythm point weight, rhythm slot weight
getRhythmSlotWeights
transforms Array<RhythmMap> to Array<RhythmSlotWeight>
const rhythmSlotWeights = getRhythmSlotWeights(
getRhythmGroup({
baseStructure: {
structureType: "initial",
rhythmResolution: 5,
},
memberStructure: {
structureType: "terminal",
density: 3,
},
}).map(getRhythmMap)
);
// rhythmSlotWeights === [3, 1, 2, 2, 1];
getRhythmString
transforms RhythmMap to RhythmString
const rhythmString = getRhythmString(
getRhythmMap({
structureType: "initial",
rhythmResolution: 5,
subStructure: {
structureType: "terminal",
rhythmDensity: 3,
rhythmOrientation: 0,
},
})
);
// rhythmString === "11010"
getRhythmWeight
computes RhythmWeight from RhythmMap and Array<RhythmSlotWeight>
const rhythmGrouphRythmMaps = getRhythmGroup({
baseStructure: {
structureType: "initial",
rhythmResolution: 5,
},
memberStructure: {
structureType: "terminal",
rhythmDensity: 3,
},
}).map(getRhythmMap);
const rhythmWeight = getRhythmWeight(
rhythmGroupMemberRhythmMaps[0],
getRhythmSlotWeights(rhythmGroupMemberRhythmMaps)
);
// rhythmWeight === 6
rhythm weight, rhythm slot weight
primes (functions)
getPrime
computes prime of given prime index
const prime = getPrime(3);
// prime === 7
getPrimes
computes primes up to given prime index
const primes = getPrimes(3);
// primes === [2, 3, 5, 7]
getPrimesLessThanInclusive
computes primes less than or equal to given number
const primesLessThan12 = getPrimesLessThanInclusive(12);
// primesLessThan12 = [2, 3, 5, 7, 11]
getNearestPrimes
computes the nearest prime below and above given number
const nearestPrimes = getNearestPrimes(10);
// nearestPrimes === [7, 11]
getPrimesRangeInclusive
computes primes contained within given minimum number and maximum number
const primesRange = getPrimesRangeInclusive(4, 11);
// primesRange === [5, 7, 11]
getPrimesSlice
computes primes from given minimum prime index to given maximum prime index
const primesSlice = getPrimesSlice(3, 5);
// primesSlice === [7, 11, 13]
getNumberGreaterThanPrime
computes a number greater than the prime of given prime index
const numberGreaterThan7 = getNumberGreaterThanPrime(3);
// numberGreaterThan7 === 8
isPrime
checks if given number is prime
const isFourPrime = isPrime(4);
// isFourPrime === false
getPrimeContainer
computes prime container of given prime container index
const primeContainer = getPrimeContainer(2);
// primeContainer === 12
getPrimeContainers
computes prime containers up to given prime container index
const primeContainers = getPrimeContainers(2);
// primeContainers = [4, 6, 12]
isPrimeContainer
checks if given number is prime container
const isFourPrimeContainer = isPrimeContainer(4);
// isFourPrimeContainer === true