Skip to content

Commit c9cbf5f

Browse files
committed
making sawtooth and square waves intuitively sync up with radians.
1 parent d8629c4 commit c9cbf5f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

parametricFunctions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const parametricFunctions = {
7070
},
7171
squareWave: {
7272
apply: (t, { amplitude, frequency, phase, verticalShift }) => {
73-
const period = 1 / frequency;
73+
const period = 1 / (frequency * (Math.PI * 2));
7474
const halfPeriod = period / 2;
7575
const adjustedT = (t + phase) % period;
7676
return adjustedT < halfPeriod ? amplitude + verticalShift : -amplitude + verticalShift;
@@ -79,7 +79,7 @@ export const parametricFunctions = {
7979
},
8080
sawtoothWave: {
8181
apply: (t, { amplitude, frequency, phase, verticalShift }) => {
82-
const period = 1 / frequency;
82+
const period = 1 / (frequency * (Math.PI * 2));
8383
const adjustedT = (t + phase) % period;
8484
return ((2 * amplitude) / period) * adjustedT - amplitude + verticalShift;
8585
},

0 commit comments

Comments
 (0)