Function babalcore::sawtooth_wave [−][src]
pub fn sawtooth_wave(x: f64) -> f64
Sawtooth wave func as defined here: https://en.wikipedia.org/wiki/Sawtooth_wave It alternates between values of -1 and 1, with a global period of 1. It switches between them at x == 0.5.
use babalcore::*; assert_eq!(-0.5, sawtooth_wave(-0.25)); assert_eq!(0.5, sawtooth_wave(0.25)); assert_eq!(-0.5, sawtooth_wave(0.75)); assert_eq!(0.5, sawtooth_wave(1.25));