@@ -70,20 +70,20 @@ export const parametricFunctions = {
7070 } ,
7171 squareWave : {
7272 apply : ( t , { amplitude, frequency, phase, verticalShift } ) => {
73- const period = 1 / ( frequency * ( Math . PI * 2 ) ) ;
74- const halfPeriod = period / 2 ;
73+ // Use the same frequency scaling as sine/cosine
74+ const period = ( 2 * Math . PI ) / frequency ;
7575 const adjustedT = ( t + phase ) % period ;
76- return adjustedT < halfPeriod ? amplitude + verticalShift : - amplitude + verticalShift ;
76+ return adjustedT < ( period / 2 ) ? amplitude + verticalShift : - amplitude + verticalShift ;
7777 } ,
7878 params : { amplitude : 1 , frequency : 1 , phase : 0 , verticalShift : 0 } ,
7979 } ,
8080 sawtoothWave : {
8181 apply : ( t , { amplitude, frequency, phase, verticalShift } ) => {
82- const period = 1 / ( frequency * ( Math . PI * 2 ) ) ;
82+ // Use the same frequency scaling as sine/cosine
83+ const period = ( 2 * Math . PI ) / frequency ;
8384 const adjustedT = ( t + phase ) % period ;
8485 return ( ( 2 * amplitude ) / period ) * adjustedT - amplitude + verticalShift ;
8586 } ,
8687 params : { amplitude : 1 , frequency : 1 , phase : 0 , verticalShift : 0 } ,
8788 } ,
88- // Add more functions as needed
8989} ;
0 commit comments